char angka[10][7]={
{1,1,1,1,1,1,0}, // angka 0
{0,1,1,0,0,0,0}, // angka 1
{1,1,0,1,1,0,1}, // angka 2
{1,1,1,1,0,0,1}, // angka 3
{0,1,1,0,0,1,1}, // angka 4
{1,0,1,1,0,1,1}, // angka 5
{1,0,1,1,1,1,1}, // angka 6
{1,1,1,0,0,0,0}, // angka 7
{1,1,1,1,1,1,1}, // angka 8
{1,1,1,1,0,1,1} // angka 9
};
char pin7[7]={2,3,4,5,6,7,8};
int kondisi1=0,kondisi2=0,counter=0;
void tampil_angka (int nilai){
for(int i=0;i<7;i++){
digitalWrite(pin7[i],angka[nilai][i]);
}
}
void counterUp()
{
for(int count=0;count<10;count++)
{
tampil_angka(count);
delay(500);
}
}
void counterDown()
{
for(int count=0;count<10;count++)
{
tampil_angka(9-count);
delay(500);
}
}
void setup() {
// put your setup code here, to run once:
for(int i=0;i<7;i++){
pinMode(pin7[i],OUTPUT);
}
pinMode(9,INPUT);
pinMode(10,INPUT);
}
void loop() {
if(digitalRead(9)==1) counter=1;
if(digitalRead(10)==1)counter=2;
if(counter==1){
for(int count=0;count<10;count++){
tampil_angka(count);
delay(500);
}
}
if(counter==2){
for(int count=0;count<10;count++){
tampil_angka(9-count);
delay(500);
}
}
}