int A = 2;
int B = 3;
int C = 4;
int D = 5;
int E = 6;
int F = 7;
int G = 8;
int segmen1 =10;
int segmen2 =11;
int datatombol1;
int datatombol2;
int nilaidigit1;
int nilaidigit2;
void setup()
{
Serial.begin(9600);
pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);
pinMode(E, OUTPUT);
pinMode(F, OUTPUT);
pinMode(G, OUTPUT);
pinMode(segmen1, OUTPUT);
pinMode(segmen2, OUTPUT);
}
void loop() {
datatombol1=digitalRead(13);
datatombol2=digitalRead(12);
delay(75);
if (datatombol1==1)
{
nilaidigit1 ++;
}
if (datatombol2==1)
{
nilaidigit1 --;
}
if (nilaidigit1==10)
{
nilaidigit1= 0;
nilaidigit2 ++;
}
if (nilaidigit1==-1);
{
nilaidigit1= 9;
nilaidigit2 --;
}
if (nilaidigit2== -1)
{
nilaidigit2= 9;
}
if (nilaidigit2==10);
{
nilaidigit2=0;
}
Serial.println(nilaidigit1);
Serial.println(nilaidigit2);
if(nilaidigit1==0)
{
digitalWrite(segmen2, LOW);
delay(2);
nol();
digitalWrite(segmen1, HIGH);
}
else if(nilaidigit1==1)
{
digitalWrite(segmen2, LOW);
delay(2);
satu();
digitalWrite(segmen1, HIGH);
}
else if(nilaidigit1==2)
{
digitalWrite(segmen2, LOW);
delay(2);
dua();
digitalWrite(segmen1, HIGH);
}
else if (nilaidigit1==3)
{
digitalWrite(segmen2, LOW);
delay(2);
tiga();
digitalWrite(segmen1, HIGH);
}
else if (nilaidigit1==4)
{
digitalWrite(segmen2, LOW);
delay(2);
empat();
digitalWrite(segmen1, HIGH);
}
else if (nilaidigit1==5)
{
digitalWrite(segmen2, LOW);
delay(2);
lima();
digitalWrite(segmen1, HIGH);
}
else if (nilaidigit1==6)
{
digitalWrite(segmen2, LOW);
delay(2);
enam();
digitalWrite(segmen1, HIGH);
}
else if (nilaidigit1==7)
{
digitalWrite(segmen2,LOW);
delay(2);
tujuh();
digitalWrite(segmen1, HIGH );
}
else if (nilaidigit1==8)
{
digitalWrite(segmen2, LOW);
delay(2);
delapan();
digitalWrite(segmen1, HIGH);
}
else if (nilaidigit1==9)
{
digitalWrite(segmen2, LOW);
delay(2);
sembilan();
digitalWrite(segmen1, HIGH);
}
if(nilaidigit2==0)
{
digitalWrite(segmen1,LOW);
delay(2);
nol();
digitalWrite(segmen2,HIGH);
}
else if (nilaidigit2==1)
{
digitalWrite(segmen1,LOW);
delay(2);
satu();
digitalWrite(segmen2,HIGH);
}
else if (nilaidigit2==2)
{
digitalWrite(segmen1,LOW);
delay(2);
dua();
digitalWrite(segmen2,HIGH);
}
else if (nilaidigit2==3)
{
digitalWrite(segmen1,LOW);
delay(2);
tiga();
digitalWrite(segmen2,HIGH);
}
else if (nilaidigit2==4)
{ digitalWrite(segmen1,LOW);
delay(2);
empat();
digitalWrite(segmen2,HIGH);
}
else if (nilaidigit2==5)
{ digitalWrite(segmen1,LOW);
delay(2);
lima();
digitalWrite(segmen2,HIGH);
}
else if (nilaidigit2==6)
{ digitalWrite(segmen1,LOW);
delay(2);
enam();
digitalWrite(segmen2,HIGH);
}
else if (nilaidigit2==7)
{ digitalWrite(segmen1,LOW);
delay(2);
tujuh();
digitalWrite(segmen2,HIGH);
}
else if (nilaidigit2==8)
{ digitalWrite(segmen1,LOW);
delay(2);
delapan();
digitalWrite(segmen2,HIGH);
}
else if (nilaidigit2==9)
{ digitalWrite(segmen1,LOW);
delay(2);
sembilan();
digitalWrite(segmen2,HIGH);
}
}
void nol()
{
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
}
void satu()
{
digitalWrite(A, HIGH);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void dua()
{
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, HIGH);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, LOW);
}
void tiga()
{
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, LOW);
}
void empat()
{
digitalWrite(A, HIGH);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
}
void lima()
{
digitalWrite(A, LOW);
digitalWrite(B, HIGH);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
}
void enam()
{
digitalWrite(A, LOW);
digitalWrite(B, HIGH);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
}
void tujuh()
{
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, HIGH);
digitalWrite(E, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void delapan()
{
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, LOW);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
}
void sembilan()
{
digitalWrite(A, LOW);
digitalWrite(B, LOW);
digitalWrite(C, LOW);
digitalWrite(D, LOW);
digitalWrite(E, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
}