const int a = 15;
const int b = 2;
const int c = 0;
const int d = 4;
const int e = 16;
const int f = 5;
const int g = 17;
const int db = 18;
const int pot_input = 12;
int val = 0;
int display = 0;
void setup() {
Serial.begin(115200);
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
pinMode(db, OUTPUT);
pinMode(pot_input, INPUT);
}
void loop() {
// Serial.println(analogRead(pot_input));
val = analogRead(pot_input);
display = map(val, 0,4095, 0,9);
Serial.println(display);
sigment_display(display);
delay(1000);
}
void sigment_display(int num){
switch (num){
case 0:
sigment_0 ();
break;
case 1:
sigment_1 ();
break;
case 2:
sigment_2 ();
break;
case 3:
sigment_3 ();
break;
case 4:
sigment_4 ();
break;
case 5:
sigment_5 ();
break;
case 6:
sigment_6 ();
break;
case 7:
sigment_7 ();
break;
case 8:
sigment_8 ();
break;
case 9:
sigment_9 ();
break;
}
delay(100);
}
void sigment_0 () {
Serial.print("Your number is : ");
Serial.println("0");
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, HIGH);
digitalWrite(db, HIGH);
}
void sigment_1 () {
Serial.print("Your number is : ");
Serial.println("1");
digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
digitalWrite(db, HIGH);
}
void sigment_2 () {
Serial.print("Your number is : ");
Serial.println("2");
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, HIGH);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, HIGH);
digitalWrite(g, LOW);
digitalWrite(db, HIGH);
}
void sigment_3 () {
Serial.print("Your number is : ");
Serial.println("3");
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, LOW);
digitalWrite(e, HIGH);
digitalWrite(f, HIGH);
digitalWrite(g, LOW);
digitalWrite(db, HIGH);
}
void sigment_4 () {
Serial.print("Your number is : ");
Serial.println("4");
digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, LOW);
digitalWrite(g, LOW);
digitalWrite(db, HIGH);
}
void sigment_5 () {
Serial.print("Your number is : ");
Serial.println("5");
digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, LOW);
digitalWrite(d, LOW);
digitalWrite(e, HIGH);
digitalWrite(f, LOW);
digitalWrite(g, LOW);
digitalWrite(db, HIGH);
}
void sigment_6 () {
Serial.print("Your number is : ");
Serial.println("6");
digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, LOW);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, LOW);
digitalWrite(db, HIGH);
}
void sigment_7 () {
Serial.print("Your number is : ");
Serial.println("7");
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH);
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
digitalWrite(db, HIGH);
}
void sigment_8 () {
Serial.print("Your number is : ");
Serial.println("8");
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, LOW);
digitalWrite(db, HIGH);
}
void sigment_9 () {
Serial.print("Your number is : ");
Serial.println("9");
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, LOW);
digitalWrite(e, HIGH);
digitalWrite(f, LOW);
digitalWrite(g, LOW);
digitalWrite(db, HIGH);
}