#define A 2
#define B 3
#define C 4
#define D 5
#define E 6
#define F 7
#define G 8
#define DP 9
#define p_start A0
#define p_up A1
#define p_down A2
int cUp, cDown = 0;
void enol() {
for(int a = 2;a<10;a++) {
if(a == 8 || a == 9) {
digitalWrite(a, LOW);
} else {
digitalWrite(a, HIGH);
}
}
}
void satu() {
for(int b = 3;b<5;b++) {
digitalWrite(b, HIGH);
}
}
void dua() {
for(int c = 2;c<10;c++) {
if(c == 4 || c== 7 || c == 9) {
digitalWrite(c, LOW);
} else {
digitalWrite(c, HIGH);
}
}
}
void tiga() {
for(int d = 2;d <10;d++) {
if(d==6 || d==7|| d==9) {
digitalWrite(d, LOW);
} else {
digitalWrite(d, HIGH);
}
}
}
void empat() {
for(int e = 2; e < 10; e++) {
if(e == 2 || e == 5 || e == 6 || e == 9) {
digitalWrite(e, LOW);
} else {
digitalWrite(e, HIGH);
}
}
}
void lima() {
for(int f = 2; f<10;f++) {
if(f == 3 || f ==6 || f == 9) {
digitalWrite(f, LOW);
} else {
digitalWrite(f, HIGH);
}
}
}
void enam() {
for(int g = 2; g<10;g++) {
if(g == 3 || g == 9) {
digitalWrite(g, LOW);
} else {
digitalWrite(g, HIGH);
}
}
}
void tujuh() {
for(int h =2;h<5;h++) {
digitalWrite(h, HIGH);
}
}
void delapan() {
for(int i =2;i<10;i++) {
if(i == 9) {
digitalWrite(i, LOW);
} else {
digitalWrite(i, HIGH);
}
}
}
void sembilan() {
for(int j = 2;j<10;j++) {
if(j == 6 || j == 9) {
digitalWrite(j, LOW);
} else {
digitalWrite(j, HIGH);
}
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
for(int x = 2;x<10;x++) {
pinMode(x, OUTPUT);
digitalWrite(x, LOW);
}
for(int y = 0; y<3;y++) {
String alphabet = "A";
String pb = alphabet + y;
// Serial.println(pb);
pinMode(pb.toInt(), INPUT_PULLUP);
digitalWrite(pb.toInt(), HIGH);
}
enol();
}
void loop() {
// put your main code here, to run repeatedly:
// Serial.println(digitalRead(pb_start));
bool pb_start = digitalRead(p_start);
bool pb_up = digitalRead(p_up);
bool pb_down = digitalRead(p_down);
// Up & Down
if(pb_up == 1 && cUp >= 0) {
delay(15);
cUp = cUp + 1;
Serial.println(cUp);
while(digitalRead(p_up));
} else if(pb_down == 1 && cDown >= 0) {
delay(15);
cUp = cUp - 1;
if(cUp < 0) {
cUp = 0;
}
cDown = cUp;
Serial.println(cDown);
while(digitalRead(p_down));
}
if(pb_start == 1 && cUp > 0) {
delay(10);
Serial.print("Start cUp");
if(cUp == 1) {
satu();
} else if(cUp == 2) {
dua();
} else if(cUp == 3) {
tiga();
} else if(cUp == 4) {
empat();
} else if(cUp == 5) {
lima();
} else if(cUp == 6) {
enam();
} else if(cUp == 7) {
tujuh();
} else if(cUp == 8) {
delapan();
} else if(cUp >= 9) {
sembilan();
}
} else if(pb_start == 1 && cDown >= 0) {
delay(10);
Serial.print("Start cDown");
if(cDown <= 0) {
enol();
} else if(cDown == 1) {
satu();
} else if(cDown == 2) {
dua();
} else if(cDown == 3) {
tiga();
} else if(cDown == 4) {
empat();
} else if(cDown == 5) {
lima();
} else if(cDown == 6) {
enam();
} else if(cDown == 7) {
tujuh();
} else if(cDown == 8) {
delapan();
} else if(cDown >= 9) {
sembilan();
}
}
}