Hallo,
brauche Hilfe bei meinem kleinem Projekt.
habe 4 Buttons und 4 LEDs mit esp32 erfolgreich verbunden.
Nun ist die Frage, wie kann man es in Script umsetzen, dass sobald man auf ein Button klickt 3 LED ausgehen und eine an bleibt?
const int ledPinRed = 27;
const int ledPinBlue = 26;
const int ledPinYellow = 25;
const int ledPinGreen = 33;
//Buttons
const int PushButton = 34;
//const int analogInPin = 34;
void setup() {
Serial.begin(115200);
pinMode (ledPinRed, OUTPUT);
pinMode (ledPinBlue, OUTPUT);
pinMode (ledPinYellow, OUTPUT);
pinMode (ledPinGreen, OUTPUT);
pinMode(PushButton, INPUT);
}
void loop() {
int Push_button_state = digitalRead(PushButton);
Serial.println(Push_button_state);
if ( Push_button_state == HIGH )
{
digitalWrite (ledPinBlue, HIGH); // turn on the LED
delay(500); // wait for half a second or 500 milliseconds
digitalWrite (ledPinBlue, LOW); // turn off the LED
delay(500); // wait for half a second or 500 milliseconds
digitalWrite (ledPinYellow, HIGH); // turn on the LED
delay(500); // wait for half a second or 500 milliseconds
digitalWrite (ledPinYellow, LOW); // turn off the LED
delay(500); // wait for half a second or 500 milliseconds
digitalWrite (ledPinGreen, HIGH); // turn on the LED
delay(500); // wait for half a second or 500 milliseconds
digitalWrite (ledPinGreen, LOW); // turn off the LED
delay(500); // wait for half a second or 500 milliseconds
}else{
digitalWrite (ledPinRed, HIGH); // turn on the LED
delay(500); // wait for half a second or 500 milliseconds
digitalWrite (ledPinRed, LOW); // turn off the LED
delay(500); // wait for half a second or 500 milliseconds
}
}
//commandState = analogRead(analogInPin);
//ausgabe muss hier 4 unterschieldich Werte anzeigen.
//Serial.println(commandState);
//delay(500);