Udp.sendPacket whit analog_input

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
cutprod
 
Posts: 3
Joined: Fri Nov 25, 2011 9:40 am

Udp.sendPacket whit analog_input

Post by cutprod »

Hello everyone and congratulations to the forum!
I started with the Arduino.
I will wish to use the "Udp.sendPacket" and "Udp.readPacket" to write and read the value of an analog input.
But I'm stuck! I was not able to convert my variable of type int to char smiley-cry
How?

Code: Select all

 Udp.sendPacket( analogRead(9), remoteIp, remotePort); 
Thank you in advance if anyone can help me!

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Udp.sendPacket whit analog_input

Post by adafruit_support_bill »


cutprod
 
Posts: 3
Joined: Fri Nov 25, 2011 9:40 am

Re: Udp.sendPacket whit analog_input

Post by cutprod »

thank you very much I will test !

computerchi
 
Posts: 1
Joined: Fri Nov 25, 2011 3:56 pm

Re: Udp.sendPacket whit analog_input

Post by computerchi »

Hi cutprod,

If you want to convert an int to char you can do so through type casting. For example;

int i = 10;
char c = (char) i;

The itoa() converts an int to a zero-terminated string. They are not the same.

Regards,

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”