Sending X Y Coordinates Through Serial USB?
i brannew processing/arduino.
taking class @ school, class behind me, , teacher won't me out until class catches up.
i need figure out how x , y coords arduino through serial usb.
i cant figure out atoi thing. (but understand should - ascii integer)
so.... arduino takes bites, or something.
you have convert ascii stuff.
and have number 255.
i thought simple task. need coords program , taking lot longer want to.
spent few hours looking @ other posts!
i pretty sure
http://www.arduino.cc/cgi-bin/yabb2/yabb.pl?num=1231650517
is trying do.
i cant make sense of it.
taking class @ school, class behind me, , teacher won't me out until class catches up.
i need figure out how x , y coords arduino through serial usb.
i cant figure out atoi thing. (but understand should - ascii integer)
so.... arduino takes bites, or something.
you have convert ascii stuff.
and have number 255.
i thought simple task. need coords program , taking lot longer want to.
spent few hours looking @ other posts!
i pretty sure
http://www.arduino.cc/cgi-bin/yabb2/yabb.pl?num=1231650517
is trying do.
i cant make sense of it.
are x, y coords being sent processing? strings or numbers? sent 1 @ time, or together?
if data being sent processing string data, , numbers sent together, need include sort of beginning of packet , end of packet markers, delimiter between values. send string this:
<12, 45>
the arduino can read serial data, discarding data until sees <. then, knows data stream contains valid data.
it reads 1 character @ time, looking character represents digit, comma, space, > or <.
if character represents digit, converts character number, subtracting '0' ('8' - '0' = 8; '5' - '0' = 5). multiplies previous value 10 , adds new value:
if x 8 , n 4, 8 * 10 = 80, plus 4 = 84.
if character is, instead, comma or space, discarded, rest of string goes in y. if character >, end of packet has been received, , x , y can used.
if character <, packet not sent, values in x , y reset, , new packet processed.
if data sent numbers, 2 bytes (which limited 0 255) can read , used.
if data being sent processing string data, , numbers sent together, need include sort of beginning of packet , end of packet markers, delimiter between values. send string this:
<12, 45>
the arduino can read serial data, discarding data until sees <. then, knows data stream contains valid data.
it reads 1 character @ time, looking character represents digit, comma, space, > or <.
if character represents digit, converts character number, subtracting '0' ('8' - '0' = 8; '5' - '0' = 5). multiplies previous value 10 , adds new value:
code: [select]
x *= 10;
x += n;if x 8 , n 4, 8 * 10 = 80, plus 4 = 84.
if character is, instead, comma or space, discarded, rest of string goes in y. if character >, end of packet has been received, , x , y can used.
if character <, packet not sent, values in x , y reset, , new packet processed.
if data sent numbers, 2 bytes (which limited 0 255) can read , used.
Arduino Forum > Forum 2005-2010 (read only) > Software > Interfacing > Sending X Y Coordinates Through Serial USB?
arduino
Comments
Post a Comment