Hello Forum
I have this simple sketch:
const int etned = 2; // the pin that the LED is attached to
const int etop = 3;
const int toned = 4;
const int toop = 5;
byte serialA;
void setup()
{
// initialize the serial communication:
Serial.begin(9600); //baud rate - make sure it matches that of the module you got:
// initialize the ledPin as an output:
pinMode(etned, OUTPUT);
pinMode(etop, OUTPUT);
pinMode(toned, OUTPUT);
pinMode(toop, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
serialA = Serial.read();
Serial.println(serialA);
}
switch (serialA) {
case 1:
digitalWrite(etned, HIGH);
delay(1000);
digitalWrite(etned, LOW);
break;
case 2:
digitalWrite(toned, HIGH);
delay(1000);
digitalWrite(toned, LOW);
break;
default:
break;
}
}
When I run it, and sends the numbers 1 or 2 through a terminal, the cases are executed almost right, the pins are going high, but not low again, after the delay function. How can I make the pin go low after the delay? - right now they are just staying high.
I think there is a very simple solution to this, but I can't find it...
Thank you very much
best regards
JohannesTN