haw can arduino read a string ?


hello
i can't understand how arduino read string ? in code led on !
code: [select]
int rled = 12;

void setup() { 
   serial.begin (9600);   
   pinmode(rled, output);   
   digitalwrite(rled, low);
   }

void loop() {
   while (serial.available()) {
    // new byte:
    char inchar = (char)serial.read();
    // add inputstring:
    inputstring += inchar;
    }
    if(inputstring == "on"){
       digitalwrite(rled, high);       
   }
   if(inputstring == "off"){
      digitalwrite(rled, low);       
   }
}



Arduino Forum > Using Arduino > Programming Questions > haw can arduino read a string ?


arduino

Comments