Warum kann meine IF -Statement -Schleife auf Arduino IDE nicht?

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Warum kann meine IF -Statement -Schleife auf Arduino IDE nicht?

by Anonymous » 26 Aug 2025, 07:25

Ich möchte, dass meine LED drei Zustände mit Druckknopf < /p>

On < /li>
Blinking < /li>
Off < /li>
< /ol>
hat, aber der zweite Zustand blank nicht. Hier ist der Code: < /p>

Code: Select all

#define btn 7
#define led 8
int button;
int a;

void setup() {
Serial.begin(9600);
pinMode(led,OUTPUT);
pinMode(btn,INPUT);
// put your setup code here, to run once:

}

void loop() {
Serial.print("a==");
Serial.println(a);
button = digitalRead(btn);
if(button ==1){
delay(100);
a++;

if(a ==1){
delay(100);
digitalWrite(led,HIGH);
}
if(a == 2){
digitalWrite(led,LOW);
delay(500);
digitalWrite(led,HIGH);
delay(500);
}
if(a ==3){
digitalWrite(led,LOW);
delay(100);
a = 0;
}
}
}

Ich habe versucht, während der Anweisung zu verwenden, aber ich konnte nicht verstehen, wie es funktioniert 😓😓

Top