void setup() {
DDRD = B11111111;
DDRB = B00000011;
for(int led = 0; led<10; led++){
pinMode(led, OUTPUT);
}
for(int button = 10; button<13; button++){
pinMode(button, INPUT_PULLUP);
}
}
void loop(){
if(digitalRead(10)==LOW){
for(int led = 0; led<10; led++){
digitalWrite(led, HIGH);
delay(200);
}
for(int led = 9; led>=0; led--){
digitalWrite(led, LOW);
delay(200);
}
for(int led = 0; led<10; led++){
digitalWrite(led, HIGH);
delay(200);
digitalWrite(led, LOW);
delay(200);
}
for(int led = 9; led>=0; led--){
digitalWrite(led, HIGH);
delay(200);
digitalWrite(led, LOW);
delay(200);
}
turnOff();
}delay(500);
if(digitalRead(11)==LOW){
int i, a ,b ,c;
for(i = 0; i<=7; i++){
a = i%2;
b = i/2%2;
c = i/4%2;
digitalWrite(0,a);
digitalWrite(1,b);
digitalWrite(2,c);
binaryLedEquivalent(i);
turnOff();
delay(200);
}
}delay(500);
}
void binaryLedEquivalent(int i){
if(i== 1){
PORTD = B00001000;
}
if(i == 2){
PORTD = B00011000;
}
if(i == 3){
PORTD = B00111000;
}
if(i ==4){
PORTD = B01111000;
}
if(i == 5){
PORTD = B11111000;
}
if(i == 6){
PORTD = B11111000;
PORTB = B00000001;
}
if(i == 7){
PORTD = B11111000;
PORTB = B00000011;
}
}
void turnOff(){
for(int led = 0;led<10; led++){
digitalWrite(led, LOW);
}
}