Thanks for both your replies ![]()
groundFungus:
Just dowhile(Serial.available) // while there are bytes in the serial buffer
{
Serial.read(); //read the bytes and throw them away
}
That will empty the serial buffer.
Adding your suggestion did, to my surprise, not change anything. So to problem had to be somewhere else than the serial buffer.
The thing I couldn't explain was that the second row from the serial monitor screenshot had multiple C’s in it.
if (incomingByte == 'A' || incomingByte == 'B' || incomingByte == 'C' || incomingByte == 'D' || incomingByte == 'E' || incomingByte == 'F')
{
Serial.print(incomingByte);
servo1.write(20);
}
looking at the statement above I finally became clear that the Character C was stilling being send on the moment this part of code ran. Increasing the delay time in the first sketch from 1 to 100 milliseconds did solve this issue.
if(total3 > 200){
Serial.print('C');
delay(100);
}
I am curious why you need 2 Nanos. If you are short on pins, note that the analog inputs can be used as digital pins (6 pins).
Thanks for the tip. I was aware of this. The total pins needed is,unfortunately, 20+
And why all the code in setup with a while(1). That is what loop() is for.
Just a bad practice I think ![]()