hello
I,m sending some variable in size ascii string to arduino mega and ethernet shield via udp library.
the messages are multiples of 5 and maximum of 512 and this will be one :
1823202122 in ascii
i would like to get this char array from udp and convert it into uint8 to apply to a function for example analogWrite.
so the first 18 will be apply to
analogWrite(0,uint8Byte[0]; this will be 18
analogWrite(0,uint8Byte[1]; this will be 23
analogWrite(0,uint8Byte[2]); this will be 20
and so on.
i tried different things i saw the most used way is the atoi but tried with no success .
void loop() {
// if there's data available, read a packet
int packetSize = Udp.parsePacket();
if(packetSize)
{
// read the packet into packetBufffer
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
for ( int i = 0; i <MAX_DATA_ELEMENTS; i++) {
//int input = atoi(&packetBuffer[i]);
input[i] = atoi(&packetBuffer[i]);
//input[i] = packetBuffer[i];
// for (i=0; i<strlen(str); i++)
analogWrite(5,input[0]); //Test for the Analog Pin 5
}
delay(2);
}
}
could you please show me the right way to do it so i can use incoming string as an array of uint8?
cheers