int butonp = 8; //siyah int butonq = 9; //beyaz int led = 7; //yeşil-gri int p = 0; int q = 0; int dugme_ve = 5; //kırmızı int dugme_veya = 4; //turuncu int dugme_yada = 3; //sarı int dugme_ise = 2; //mor int dugme_ancak = 1; //mavi void setup() { pinMode(led, OUTPUT); pinMode(butonp, INPUT_PULLUP); pinMode(butonq, INPUT_PULLUP); pinMode(dugme_ve, INPUT_PULLUP); pinMode(dugme_veya, INPUT_PULLUP); pinMode(dugme_yada, INPUT_PULLUP); pinMode(dugme_ise, INPUT_PULLUP); pinMode(dugme_ancak, INPUT_PULLUP); } void ve() { if ((q == LOW) && (p == LOW)) { digitalWrite(led, HIGH); delay(250); } else { digitalWrite(led, LOW); delay(250); } } void veya() { if ((q == LOW) or (p == LOW)) { digitalWrite(led, HIGH); delay(250); } else { digitalWrite(led, LOW); delay(250); } } void yada() { if ((q == LOW) && (p == LOW)) { digitalWrite(led, LOW); delay(250); } else if ((q == LOW) && (p == HIGH)) { digitalWrite(led, HIGH); delay(250); } else if ((q == HIGH) && (p == LOW)) { digitalWrite(led, HIGH); delay(250); } else { digitalWrite(led, LOW); delay(250); } } void ise() { if ((q == LOW) && (p == LOW)) { digitalWrite(led, HIGH); delay(250); } else if ((q == HIGH) && (p == LOW)) { digitalWrite(led, LOW); delay(250); } else if ((q == HIGH) && (p == LOW)) { digitalWrite(led, HIGH); delay(250); } else { digitalWrite(led, HIGH); delay(250); } } void ancak() { if ((q == LOW) && (p == LOW)) { digitalWrite(led, HIGH); delay(250); } else if ((q == HIGH) && (p == LOW)) { digitalWrite(led, LOW); delay(250); } else if ((q == LOW) && (p == HIGH)) { digitalWrite(led, LOW); delay(250); } else { digitalWrite(led, HIGH); delay(250); } } void loop() { digitalWrite(led, LOW); p = digitalRead(butonp); q = digitalRead(butonq); if (digitalRead(dugme_ve) == LOW) { ve(); delay(50); } else if (digitalRead(dugme_veya) == LOW) { veya(); delay(50); } else if (digitalRead(dugme_yada) == LOW) { yada(); delay(50); } else if (digitalRead(dugme_ise) == LOW) { ise(); delay(50); } else if (digitalRead(dugme_ancak) == LOW) { ancak(); delay(50); } else { digitalWrite(led, LOW); delay(50); } }
No responses yet