void setup() {
// put your setup code here, to run once:
DDRA=0XFF;
DDRC=0XFF;
DDRD=0X00;
attachInterrupt(digitalPinToInterrupt(18),SW1, FALLING);
attachInterrupt(digitalPinToInterrupt(19),SW2, FALLING);
attachInterrupt(digitalPinToInterrupt(20),SW3, FALLING);
attachInterrupt(digitalPinToInterrupt(21),SW4, FALLING);
}
int ledout=0;
int fnd[9]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80};
int number=1;
int mode=0;
int mode_cnt=0;
void SW1() {
mode_cnt=0;
mode=1;
}
void SW2() {
mode_cnt=1;
mode=2;
}
void SW3() {
if(mode_cnt==1) {
delay(300);
ledout--;
number--;
}
}
void SW4() {
ledout=0;
number=0;
mode_cnt=0;
mode=0;
}
void loop() {
// put your main code here, to run repeatedly:
switch(mode) {
case 0:
PORTA=0X00;
PORTC=fnd[0];
break;
case 1:
PORTA=1<<ledout;
PORTC=fnd[number];
delay(300);
ledout++;
number++;
if(ledout>7) {
number=1;
ledout=0;
}
break;
case 2:
PORTA=1<<ledout;
PORTC=fnd[number];
if(ledout<0) {
number=8;
ledout=7;
}
break;
}
}