// x a b c d f g
//0: 0 1 1 1 1 1 0 0x7E
//1: 0 0 1 1 0 0 0 0x30
// 0 1 2 3 4 5 6 7 8 9
// 0x3f 0x6 0x5b 0x4f 0x66 0x6d 0x7d 0x7 0x7f 0x6f
//int digit[]={0b00111111,0b00000110,0b01011011,0b01001111,0b01100110,0b01101101,0b01111101,0b00000111,0b01111111,0b01101111};
int digit[]={0x3f,0x6,0x5b,0x4f,0x66,0x6d,0x7d,0x7,0x7f,0x6f,};
int x = 0;
void setup() {
// put your setup code here, to run once:
//Serial.begin(115200);
DDRD = 0xFF;
DDRB = 0x3e;
PORTB |= 0b000001;//0x1
PORTD |=0x80;
randomSeed(analogRead(A0));
x = random(1,10);
//int x = 0;
}
void loop(){
// put your main code here, to run repeatedly:
int k = digit[x];
pinMode(7, INPUT_PULLUP);
if(digitalRead(7)==LOW && x>0){
x --;
delay(300);
}
if(digitalRead(8)==LOW && x<9){
x ++;
delay(300);
}
for (int x = 0;x<7;x++){
int temp = k & 0x01;
digitalWrite(x,temp);
k=k>>1;
}
}
/*
void loop() {
// put your main code here, to run repeatedly:
bool dol = PIND & 0x80;
bool gor = PINB & 0x1;
if(dol == LOW){
x--;
delay(500);
if(x<=0)x=0;
}
if(dol == LOW){
x++;
delay(500);
if(x<=0)x=0;
}
PORTD = digit[x] | 0x80;
delay(500);
}
*/