PınarSu151
Üye
- Katılım
- 23 Ocak 2021
- Mesajlar
- 8
- Puanları
- 1
- Yaş
- 25
Merhaba, ben bu devrede her yeni bir tuşa basıldığında önceki komutun iptal edilmesini istiyorum bunu nasıl yapabilirim?
Kod:
const int led1 = 6;
const int buton1 = 0;
int butondurum1=0;
const int led2 = 7;
const int buton2 = 1;
int butondurum2=0;
const int led3 = 8;
const int buton3 = 2;
int butondurum3=0;
const int led4 = 9;
const int buton4 = 3;
int butondurum4=0;
const int led5 = 10;
const int buton5 = 4;
int butondurum5=0;
const int led6 = 11;
const int buton6 = 5;
int butondurum6=0;
void setup()
{
pinMode(led1,OUTPUT);
pinMode(buton1,INPUT);
pinMode(led2,OUTPUT);
pinMode(buton2,INPUT);
pinMode(led3,OUTPUT);
pinMode(buton3,INPUT);
pinMode(led4,OUTPUT);
pinMode(buton4,INPUT);
pinMode(led5,OUTPUT);
pinMode(buton5,INPUT);
pinMode(led6,OUTPUT);
pinMode(buton6,INPUT);
}
void loop()
{
butondurum1 = digitalRead(buton1);
butondurum2 = digitalRead(buton2);
butondurum3 = digitalRead(buton3);
butondurum4 = digitalRead(buton4);
butondurum5 = digitalRead(buton5);
butondurum6 = digitalRead(buton6);
if(butondurum1 == HIGH)
{
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
digitalWrite(led4,LOW);
digitalWrite(led5,LOW);
digitalWrite(led6,LOW);
digitalWrite(led1,HIGH);
delay(500);
digitalWrite(led1,LOW);
digitalWrite(led6,HIGH);
delay(9999);
}
else if(butondurum2 == HIGH)
{
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
delay(500);
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led6,HIGH);
delay(2000);
}
else if(butondurum3 == HIGH)
{
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
digitalWrite(led4,LOW);
digitalWrite(led5,LOW);
digitalWrite(led6,LOW);
digitalWrite(led1,HIGH);
delay(250);
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
delay(250);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
delay(250);
digitalWrite(led3,LOW);
digitalWrite(led4,HIGH);
delay(250);
digitalWrite(led4,LOW);
digitalWrite(led5,HIGH);
delay(250);
digitalWrite(led5,LOW);
digitalWrite(led6,HIGH);
delay(9999);
}
else if(butondurum4 == HIGH)
{
digitalWrite(led4,HIGH);
delay(250);
digitalWrite(led4,LOW);
delay(250);
digitalWrite(led3,HIGH);
delay(250);
digitalWrite(led3,LOW);
delay(250);
digitalWrite(led4,HIGH);
delay(250);
digitalWrite(led4,LOW);
delay(250);
digitalWrite(led3,HIGH);
delay(250);
digitalWrite(led3,LOW);
delay(250);
digitalWrite(led4,HIGH);
delay(250);
digitalWrite(led4,LOW);
delay(250);
digitalWrite(led3,HIGH);
delay(250);
digitalWrite(led3,LOW);
delay(9999);
}
else if(butondurum5 == HIGH)
{
digitalWrite(led6,HIGH);
delay(250);
digitalWrite(led6,LOW);
digitalWrite(led5,HIGH);
delay(250);
digitalWrite(led5,LOW);
digitalWrite(led4,HIGH);
delay(250);
digitalWrite(led4,LOW);
digitalWrite(led3,HIGH);
delay(250);
digitalWrite(led3,LOW);
digitalWrite(led2,HIGH);
delay(250);
digitalWrite(led2,LOW);
digitalWrite(led1,HIGH);
delay(250);
digitalWrite(led1,LOW);
digitalWrite(led6,HIGH);
delay(9999);
}
else if(butondurum6 == HIGH)
{
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
digitalWrite(led4,HIGH);
digitalWrite(led5,HIGH);
digitalWrite(led6,HIGH);
delay(500);
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
digitalWrite(led4,LOW);
digitalWrite(led5,LOW);
digitalWrite(led6,LOW);
delay(500);
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
digitalWrite(led4,HIGH);
digitalWrite(led5,HIGH);
digitalWrite(led6,HIGH);
delay(500);
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
digitalWrite(led4,LOW);
digitalWrite(led5,LOW);
digitalWrite(led6,LOW);
delay(500);
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
digitalWrite(led4,HIGH);
digitalWrite(led5,HIGH);
digitalWrite(led6,HIGH);
delay(500);
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
digitalWrite(led4,LOW);
digitalWrite(led5,LOW);
digitalWrite(led6,LOW);
}
else
{
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
digitalWrite(led4,LOW);
digitalWrite(led5,LOW);
digitalWrite(led6,LOW);
}
}