Simple variable question


i'm trying read information keyboard via serial.read function, cant figure out proper variable type.  i want able "hey user! tell me angle of servo!".  right i've been using int pos =serial.read();  and i'm getting odd numbers.

how can "20" when type "20" on keyboard?

your call to serial.read() returns integer value of each ascii character send down serial port arduino ide. table of corresponding numeric values of each character, see page.

so, if type "20" in serial monitor window, successive calls serial.read() return numbers 50 48. program needs unravel values , convert them integer value.

you need first check see when input available on serial port input, via serial.available().

check out of examples here.


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Simple variable question


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums