Hallo Leute bei dem unten Angegebenen Sketch sieht man das wen count richtig ist und der Taster gedrückt ist die LEDS in Reihenfolge blinken sollen.
Ich möchte das die LEDS nicht mehr aufhören zu blinken was muss ich da noch ergänzen?
int taster1=7;
int taster2=8;
int tasterstatus2=0;
int led1=12;
int led2=11;
int led3=10;
int led4=9;
bool oldButtonState = HIGH;
bool newButtonState;
int count = 0;
void setup() {
pinMode (taster1,INPUT);
pinMode (taster2,INPUT);
pinMode (led1,OUTPUT);
pinMode (led2,OUTPUT);
pinMode (led3,OUTPUT);
pinMode (led4,OUTPUT);
}
void loop() {
newButtonState = digitalRead(taster1);
tasterstatus2 = digitalRead(taster2);
if (oldButtonState == HIGH && newButtonState == LOW) {
count++;
oldButtonState = newButtonState;
if (count == 1) {
digitalWrite(led1, HIGH);
}
if (count == 2) {
digitalWrite(led1, LOW);
digitalWrite (led2,HIGH);
}
if (count == 3 ){
digitalWrite (led2,LOW);
digitalWrite (led3,HIGH);
}
if (count == 4){
digitalWrite (led3,LOW);
digitalWrite (led4,HIGH);
}
if (count == 5){
digitalWrite (led4,LOW);
count = 0;
}
if ((tasterstatus2 == HIGH) && (count == 1)){
digitalWrite (led1,HIGH);
digitalWrite (led2,LOW);
digitalWrite (led3,LOW);
digitalWrite (led4,LOW);
delay (1000);
digitalWrite (led1,LOW);
digitalWrite (led2,HIGH);
delay (1000);
digitalWrite (led2,LOW);
digitalWrite (led3,HIGH);
delay (1000);
digitalWrite (led3,LOW);
digitalWrite (led4,HIGH);
delay (1000);
digitalWrite (led4,LOW);
}
if ((tasterstatus2 == HIGH ) &&( count == 2)){
digitalWrite (led1,LOW);
digitalWrite (led2,HIGH);
digitalWrite (led3,LOW);
digitalWrite (led4,LOW);
delay (1000);
digitalWrite (led3,HIGH);
digitalWrite (led2,LOW);
delay (1000);
digitalWrite (led3,LOW);
digitalWrite (led4,HIGH);
delay (1000);
digitalWrite (led4,LOW);
digitalWrite (led1,HIGH);
delay (1000);
digitalWrite (led1,LOW);
}
if ((tasterstatus2 == HIGH) && (count == 3)){
digitalWrite (led1,LOW);
digitalWrite (led2,LOW);
digitalWrite (led3,HIGH);
digitalWrite (led4,LOW);
delay (1000);
digitalWrite (led3,LOW);
digitalWrite (led4,HIGH);
delay (1000);
digitalWrite (led4,LOW);
digitalWrite (led1,HIGH);
delay (1000);
digitalWrite (led1,LOW);
digitalWrite(led2,HIGH);
delay (1000);
digitalWrite (led2,LOW);
delay (1000);
}
if ((tasterstatus2 == HIGH) && (count == 4)){
digitalWrite (led1,LOW);
digitalWrite (led2,LOW);
digitalWrite (led3,LOW);
digitalWrite (led4,HIGH);
delay (1000);
digitalWrite (led4,LOW);
digitalWrite (led1,HIGH);
delay (1000);
digitalWrite (led1,LOW);
digitalWrite (led2,HIGH);
delay (1000);
digitalWrite (led2,LOW);
digitalWrite (led3,HIGH);
delay (1000);
digitalWrite (led3,LOW);
}