Apparent bug

When I try the attached sketch, I see at least two strange behaviors, as listed below:

The value of CurrentCharacterLocation is not correct, it remains at 1

I am using the latest version of the IDE.

Any suggestion?

Thanks,

Mo

Panda_LED_switching.ino (7.88 KB)

If you post your code as described in the how to use this forum sticky more members will see it.

Every time through loop, you check to see if Serial.available() >0 and if it is not, you reset CurrentCharacterLocation back to zero. When a char arrives, it increments but probably cycles through the loop again before the next character can arrive. Serial communication is very slow compared to the speed of the processor. At 9600 baud, it takes about 1 msec to retrieve a character. At 16MHz, the processor can execute 1.6M instructions in that same amount of time.

You should not be resetting things just because there is no serial input available.

blh64:
At 9600 baud, it takes about 1 msec to retrieve a character. At 16MHz, the processor can execute 1.6M instructions in that same amount of time.

I agree with the sentiment, but not the number.