You're right, eyes never been drier after hours and hours of trying to resolve this... :o
So, here is the code...
char x;
void setup() {
Serial.begin(9600);
for (int i = 0; i <= 3; i++)
{
pinMode(10, OUTPUT);
}
}
void loop() {
if ( Serial.available() )
{
x = Serial.read();
}
if ( x == 'p' )
{
digitalWrite (10, HIGH);
delay(500);
digitalWrite (10, LOW);
delay(500);
}
if ( x == 'h' )
{
digitalWrite (10, LOW);
}
}
I'm trying to understand why when I'm using " if (Serial.available()) " I can get LED blink forever (until I send 'h' in this case), but when I'm using while instead of if, LED go through blinks just one time and stops...
I'm trying to understand why when I'm using " if (Serial.available()) " I can get LED blink forever (until I send 'h' in this case), but when I'm using while instead of if, LED go through blinks just one time and stops...
I have this feeling that it's the other way round.
Well...
Suppose I tell you:
While you are awake, blink your eyes,
you will probably see yourself blinking your eyes all day.
And suppose I tell you:
If you see the flag rise, blink your eyes.
Now, how many times do you see yourself blink?