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.:
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



Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Serial ASCII conversion to int


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