Skip to content

Instantly share code, notes, and snippets.

@xandout
Created February 17, 2014 00:59
Show Gist options
  • Save xandout/9042926 to your computer and use it in GitHub Desktop.
Save xandout/9042926 to your computer and use it in GitHub Desktop.
7 Digit Display
int pins[7];
void setup(){
pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pins[0] = 3;
pins[1] = 2;
pins[2] = 5;
pins[3] = 6;
pins[4] = 7;
pins[5] = 9;
pins[6] = 10;
//pins[7] = 4;
Serial.begin(9600);
}
void loop(){
for(int x = 0; x<10; x++){
disNum(x);
delay(2000);
clearNum();
}
}
void clearNum(){
for(int x=0; x<7; x++){
digitalWrite(pins[x], LOW);
Serial.print("--");
Serial.println(pins[x]);
}
return;
}
void disNum(int number){
//Displays a single digit number using a ELS321HDB, RS#276-0075
/*
10 mid 1 top(Pin3 to allow Serial)
9 left top 2 right top
8 ground 3 ground
7 left bottom 4 right dot(unused here)
6 bottom 5 right bottom
Using Arduino Uno REV.3
Pins 3,2,5,6,7,9,10
*/
clearNum();
switch(number){
case 10: //dot
digitalWrite(4, HIGH);
Serial.println(10);
break;
case 0:
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(10, HIGH);
Serial.println(number);
break;
case 1:
digitalWrite(2, HIGH);
digitalWrite(5, HIGH);
Serial.println(number);
break;
case 2:
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(9, HIGH);
Serial.println(number);
break;
case 3:
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(9, HIGH);
Serial.println(number);
break;
case 4:
digitalWrite(2, HIGH);
digitalWrite(5, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
Serial.println(number);
break;
case 5:
digitalWrite(3, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
Serial.println(number);
break;
case 6:
digitalWrite(3, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
Serial.println(number);
break;
case 7:
digitalWrite(3, HIGH);
digitalWrite(2, HIGH);
digitalWrite(5, HIGH);
Serial.println(number);
break;
case 8:
digitalWrite(3, HIGH);
digitalWrite(2, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
Serial.println(number);
break;
case 9:
digitalWrite(3, HIGH);
digitalWrite(2, HIGH);
digitalWrite(5, HIGH);
digitalWrite(9, HIGH);
digitalWrite(6, HIGH);
digitalWrite(10, HIGH);
Serial.println(number);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment