sending serial data

Hi. I was doing some work making the arduino control a servo. i was trying to make it so that I could send a certain degree (between 0 and 180) to the arduino, and then have the servo go to that degree. the only problem was that the values i was sending were ascii values :( is there anyway to send, for example, the number 150 or 30 to the arduino through serial?

serial is just a stream of ascii characters...

if you want to send '150', you send 1, 5, 0 and decode it at the Arduino end.

Put the received values into a char buffer. Ascii "1" is decimal 49, so if you read the ascii value, you just subtract 48 from it to get the decimal value.

Have a look at the code for the Parallax GPS or the RFID reader code, both in the Playground. Both of these programs do this.


example code in this thread.