first, code...
void setup(){
Serial.begin(9600);
pinMode(13,OUTPUT);
digitalWrite(13,LOW);
}
int byteRead = 0;
void loop(){
if(Serial.available()){
byteRead = Serial.parseInt();
if(byteRead>255)digitalWrite(13,HIGH);
else analogWrite(13,byteRead);
delay(500);
}
}
problem:
when i input one value,
or if I input a series of value separated by space and when reading reach the last one
the LED have a second of delay ( someone tell me it is timeout ) before reacting to the last value.
when i put a space or any non digit at the end after the last value,
the LED have a second of delay after reacting to the last value and then turn off.
when i input a digit ( eg. 5 ) during that delay period of time,
the digit "added" to the last value ( eg. 25 ) to become a new value ( here: 25 + 5 = 255 )
So can any one tell me what the problem is and how to solve this
if I want the LED change the brightness at any moment immediately?