byte segA = 13;
byte segB = 12;
byte segC = 11;
byte segD = 10;
byte segE = 9;
byte segF = 8;
byte segG = 7;
byte high = 0;
byte low = 1;
byte pushbutton = 6;
byte get_pushbutton;
byte temporary;
void setup()
{
Serial.begin(9600);
pinMode(segA, OUTPUT);
pinMode(segB, OUTPUT);
pinMode(segC, OUTPUT);
pinMode(segD, OUTPUT);
pinMode(segE, OUTPUT);
pinMode(segF, OUTPUT);
pinMode(segG, OUTPUT);
pinMode(pushbutton, INPUT);
}
void loop()
{
get_pushbutton = digitalRead(pushbutton);
Serial.println(temporary);
if (get_pushbutton == 1)
{
numbers (3);
temporary = 9;
}
else numbers(temporary);
temporary++;
delay(1000);
if(temporary>9){
temporary = 0;
}
}
void numbers(byte basta_number) {
switch (basta_number) {
case 0:
digitalWrite(segA, high);
digitalWrite(segB, high);
digitalWrite(segC, high);
digitalWrite(segD, high);
digitalWrite(segE, high);
digitalWrite(segF, high);
digitalWrite(segG, low);
break;
case 1:
digitalWrite(segA, low);
digitalWrite(segB, high);
digitalWrite(segC, high);
digitalWrite(segD, low);
digitalWrite(segE, low);
digitalWrite(segF, low);
digitalWrite(segG, low);
break;
case 2:
digitalWrite(segA, high);
digitalWrite(segB, high);
digitalWrite(segC, low);
digitalWrite(segD, high);
digitalWrite(segE, high);
digitalWrite(segF, low);
digitalWrite(segG, high);
break;
case 3:
digitalWrite(segA, high);
digitalWrite(segB, high);
digitalWrite(segC, high);
digitalWrite(segD, high);
digitalWrite(segE, low);
digitalWrite(segF, low);
digitalWrite(segG, high);
break;
case 4:
digitalWrite(segA, low);
digitalWrite(segB, high);
digitalWrite(segC, high);
digitalWrite(segD, low);
digitalWrite(segE, low);
digitalWrite(segF, high);
digitalWrite(segG, high);
break;
case 5:
digitalWrite(segA, high);
digitalWrite(segB, low);
digitalWrite(segC, high);
digitalWrite(segD, high);
digitalWrite(segE, low);
digitalWrite(segF, high);
digitalWrite(segG, high);
break;
case 6:
digitalWrite(segA, high);
digitalWrite(segB, low);
digitalWrite(segC, high);
digitalWrite(segD, high);
digitalWrite(segE, high);
digitalWrite(segF, high);
digitalWrite(segG, high);
break;
case 7:
digitalWrite(segA, high);
digitalWrite(segB, high);
digitalWrite(segC, high);
digitalWrite(segD, low);
digitalWrite(segE, low);
digitalWrite(segF, low);
digitalWrite(segG, low);
break;
case 8:
digitalWrite(segA, high);
digitalWrite(segB, high);
digitalWrite(segC, high);
digitalWrite(segD, high);
digitalWrite(segE, high);
digitalWrite(segF, high);
digitalWrite(segG, high);
break;
case 9:
digitalWrite(segA, high);
digitalWrite(segB, high);
digitalWrite(segC, high);
digitalWrite(segD, high);
digitalWrite(segE, low);
digitalWrite(segF, high);
digitalWrite(segG, high);
break;
}
}