Hi there!
I'm new using arduino so I've begun with simple sketches like this:
[code]
int number;
void setup() {
Serial.begin(9600);
}
void loop() {
if(Serial.available()>0){
number=Serial.parseInt();
Serial.println(number);
if(numero==23){
Serial.println("Number is equal to 23");
}else if(numero>23){
Serial.println("Number is more than 23");
}else{
Serial.println("Number is less than 23");
}
}
}
[/code]
If you write a number in the serial monitor, the code compares to 23 and shows the result correctly but right after appears:
0
Number is less than 23
I've tried with other sketches and it always happens when using if(Serial.available()>0). It seems to me as if there was always a zero value in the buffer.. but I'm not an expert at all.
Any help is welcome, thanks.