Serial ASCII conversion to int
today, arduino arrived , first big project require serial data flow both directions. serial out computer looks relatively easy, i'm struggling sending serial data arduino.
the first mini-project i'm trying typing number ide serial box , dimming led accordingly.
i can type numbers 0-9 , appropriate values, when type multi-digit number, numbers individually can use values 0 9.
i know need somehow buffer data , maybe concatenate numbers char or string convert whole thing int, i'm unsure how this.
i've been searching arduino site , googling, haven't found tutorial or better explains conversion process.
here's relevant code of (everything else loop/setup definitions etc.:
storing char seems work , said, single values not entire number.
thanks in advance help.
matt
the first mini-project i'm trying typing number ide serial box , dimming led accordingly.
i can type numbers 0-9 , appropriate values, when type multi-digit number, numbers individually can use values 0 9.
i know need somehow buffer data , maybe concatenate numbers char or string convert whole thing int, i'm unsure how this.
i've been searching arduino site , googling, haven't found tutorial or better explains conversion process.
here's relevant code of (everything else loop/setup definitions etc.:
code: [select]
char analogvalue = '0';
if(serial.available()>0)
{
analogvalue=serial.read();
serial.println(analogvalue);
analogwrite(4,analogvalue);
//serial.flush();
}
storing char seems work , said, single values not entire number.
thanks in advance help.
matt
i wrote method earlier today:
http://www.arduino.cc/cgi-bin/yabb2/yabb.pl?num=1273230655/2#2
http://www.arduino.cc/cgi-bin/yabb2/yabb.pl?num=1273230655/2#2
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Serial ASCII conversion to int
arduino
Comments
Post a Comment