int a = 8; int b = 9; int c = 11; int d = 5; int e = 4; int f = 7; int g = 6; int h = 10; int keyPin = 12; // Цифра "Один" void display1(void) { digitalWrite(b,HIGH); digitalWrite(c,HIGH); } // Цифра "Два" void display2(void) { digitalWrite(a,HIGH); digitalWrite(b,HIGH); digitalWrite(g,HIGH); digitalWrite(e,HIGH); digitalWrite(d,HIGH); } // Цифра "Три" void display3(void) { digitalWrite(a,HIGH); digitalWrite(b,HIGH); digitalWrite(c,HIGH); digitalWrite(d,HIGH); digitalWrite(g,HIGH); } // Цифра "Четыре" void display4(void) { digitalWrite(f,HIGH); digitalWrite(b,HIGH); digitalWrite(g,HIGH); digitalWrite(c,HIGH); } // Цифра "Пять" void display5(void) { digitalWrite(a,HIGH); digitalWrite(f,HIGH); digitalWrite(g,HIGH); digitalWrite(c,HIGH); digitalWrite(d,HIGH); } // Цифра "Шесть" void display6(void) { digitalWrite(a,HIGH); digitalWrite(f,HIGH); digitalWrite(g,HIGH); digitalWrite(c,HIGH); digitalWrite(d,HIGH); digitalWrite(e,HIGH); } // Цифра "Семь" void display7(void) { digitalWrite(a,HIGH); digitalWrite(b,HIGH); digitalWrite(c,HIGH); } // Цифра "Восемь" void display8(void) { digitalWrite(a,HIGH); digitalWrite(b,HIGH); digitalWrite(g,HIGH); digitalWrite(c,HIGH); digitalWrite(d,HIGH); digitalWrite(e,HIGH); digitalWrite(f,HIGH); } // Цифра "Девять" void display9(void) { digitalWrite(a,HIGH); digitalWrite(b,HIGH); digitalWrite(g,HIGH); digitalWrite(c,HIGH); digitalWrite(d,HIGH); digitalWrite(f,HIGH); } // Цифра "Нуль" void display0(void) { digitalWrite(a,HIGH); digitalWrite(b,HIGH); digitalWrite(c,HIGH); digitalWrite(d,HIGH); digitalWrite(e,HIGH); digitalWrite(f,HIGH); } //Очистка дисплея void clearDisplay(void) { digitalWrite(a,LOW); digitalWrite(b,LOW); digitalWrite(g,LOW); digitalWrite(c,LOW); digitalWrite(d,LOW); digitalWrite(e,LOW); digitalWrite(f,LOW); } void setup() { int i; for(i=4;i<=11;i++) pinMode(i,OUTPUT); pinMode(keyPin,INPUT); digitalWrite(h,HIGH); display0(); } int x = -1; int switchState = 0; int oldSwitchState = 0; boolean lightsOn = false; void loop() { switchState = digitalRead(keyPin); if (switchState != oldSwitchState) { oldSwitchState = switchState; if (switchState == HIGH) { lightsOn = !lightsOn; } } if(lightsOn) { delay(100); x = x + 1; } if (x == 0) {clearDisplay(); display0();} if (x == 1) {clearDisplay(); display1();} if (x == 2) {clearDisplay(); display2();} if (x == 3) {clearDisplay(); display3();} if (x == 4) {clearDisplay(); display4();} if (x == 5) {clearDisplay(); display5();} if (x == 6) {clearDisplay(); display6();} if (x == 7) {clearDisplay(); display7();} if (x == 8) {clearDisplay(); display8();} if (x == 9) {clearDisplay(); display9();} if (x > 9) {x = 0;} }