4 Digit 7 Segment Display

Hi All,

I just built a 4 digit 7 segment display along with the code library to display different letters/digits, etc. here is it in action:

Detailed schematics and code can be found at http://www.kerrywong.com/2010/04/10/4-digit-7-segment-display-using-arduino/

Enjoy!

Very nice.

I like that you have precoded the display characters.

With mine the user has to work out his own code for character display.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1266454689/0#0

Boolean conditions for the decimal point lovely touch. Nice one. Thanks for sharing.

4 DIGIT DISPLAY FROM AN ALARM CLOCK:

I did something similar, but I didn’t need any resistors or shift registers.
I bought an alarm clock at a thrift store and took out the LED display. There were 15 wires coming out the back. By using a 5v wire and a Ground wire I was able to figure out the High/Low combinations on the different wires that would turn on different segments. It turns out that setting 1 HIGH and 2 LOW will allow half of the segments to be lit by setting other pins high, then doing the opposite and setting 1 LOW and 2 HIGH will allow the other half to be illuminated.
Then I connected each wire directly to an arduino pin and turned it into a countdown timer.

// Press a button to increase the starting minutes, then wait for
// 5 seconds and the countdown begins


int i=0;
int seconds=0;
int minutes=8;
int tens;
int ones;
int go=0;
char var=0;
int state;
int lastState;
int single;
int minutes1;
long now;
unsigned long then;
long timer=360000;
void setup()   {  
pinMode(2,INPUT);
pinMode(4,OUTPUT);  
pinMode(5, OUTPUT);     
pinMode(6, OUTPUT);   
pinMode(7, OUTPUT);   
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10, OUTPUT);   
pinMode(11, OUTPUT);   
pinMode(12, OUTPUT);   
pinMode(13,OUTPUT);
pinMode(14, OUTPUT);   
pinMode(15, OUTPUT);   
pinMode(16, OUTPUT);   
pinMode(17, OUTPUT);   
pinMode(18,OUTPUT);
pinMode(19, OUTPUT);   
// Using Serial.begin(9600) makes pin 1 stay HIGH for some reason
//Serial.begin(9600);
}


void loop()                     
{
  
  // This part starts the timer after a button press
  if(go==0){
    now=millis();
  state=digitalRead(2);
  if(state==0 && state != lastState){
   minutes++;  //increase starting minutes every time it's pressed
  
  timer=now;
}
  lastState=state;
  if(now - timer > 4000){
   go=1;  // START THE COUNTDOWN
  }
  
  }
  
 
  // This counts the seconds and minutes
  
 if (go==1) 
     {
  now=millis();
   if(now-then > 1000){
 seconds--; //count down the seconds
 then=now;
 /*
 Serial.print("Seconds: ");
 Serial.println(seconds);
  Serial.print("Minutes: ");
Serial.println(minutes);

Serial.println();
Serial.print("tens: ");
Serial.println(tens);
Serial.print("Ones: ");
Serial.println(ones);
*/
}

if(seconds<0){
 minutes--;
seconds=59;

if(minutes<0){
 seconds=0; 
}
}

     }

if(minutes>10){
 single=1;
minutes1=minutes-10; 
} else{
 single=0; 
 minutes1=minutes;
}


tens= seconds/10; //This gives the 10's digit

ones= seconds-(tens*10);  //The last digit


//FIRST NUMERAL ON THE DISPLAY


BlueFunction();
delay(5);
RedFunction();
delay(5);
}




//-----------------------------------------------------------
// THIS LIGHTS UP THE DISPLAY BY SETTING DIFFERENT PINS
// HIGH OR LOW
void BlueFunction(){
  
  digitalWrite(19,LOW);   //SET ALL TWOS LOW (RED)
 digitalWrite(18,HIGH);
 

 
  digitalWrite(17,LOW);
  digitalWrite(16,LOW);
  digitalWrite(13,LOW);
  digitalWrite(15,LOW);
 digitalWrite(14,LOW);
 digitalWrite(12,LOW);
  digitalWrite(11,LOW);
  digitalWrite(10,LOW);
  digitalWrite(9,LOW);
  digitalWrite(5,LOW);
 digitalWrite(6,LOW);
digitalWrite(4,LOW);

  digitalWrite(7,HIGH);  //Colon :      ??????????

//NOW LIGHT UP THE BLUES
//  digitalWrite(8,HIGH); // Colon :   ??????????????
  
  if(minutes1==10){
  
  digitalWrite(13,HIGH);   //0
  digitalWrite(14,HIGH);
 digitalWrite(16,HIGH);
 } else if(minutes1==9){
  digitalWrite(13,HIGH);   
  digitalWrite(15,HIGH);

  } else if(minutes1==8){
    digitalWrite(13,HIGH);   
  digitalWrite(15,HIGH);
  digitalWrite(14,HIGH);   
  digitalWrite(16,HIGH);
      
      } else if(minutes1==6){
         digitalWrite(13,HIGH);   
  digitalWrite(15,HIGH);
  digitalWrite(14,HIGH);   
  digitalWrite(16,HIGH);
        } else if(minutes1==5){
           digitalWrite(13,HIGH);   
  digitalWrite(15,HIGH);
  digitalWrite(14,HIGH);   

          } else if(minutes1==4){
             digitalWrite(13,HIGH);   
  digitalWrite(15,HIGH);
            } else if(minutes1==3){
        
  digitalWrite(15,HIGH);
  digitalWrite(14,HIGH);   
 
              } else if(minutes1==2){
                 digitalWrite(15,HIGH);
  digitalWrite(14,HIGH);   
  digitalWrite(16,HIGH);
                } 
  
  if(tens==0){                     //BLUES
    digitalWrite(11,HIGH);
    digitalWrite(10,HIGH);
    digitalWrite(12,HIGH);
  }else if(tens==9){
     digitalWrite(11,HIGH);
    digitalWrite(10,HIGH);
    digitalWrite(12,HIGH);
    }else if(tens==8){
       digitalWrite(11,HIGH);
    digitalWrite(10,HIGH);
    digitalWrite(12,HIGH);
      }else if(tens==7){
         digitalWrite(11,HIGH);
    digitalWrite(10,HIGH);
    digitalWrite(12,HIGH);
        }else if(tens==6){
         
    digitalWrite(10,HIGH);
    digitalWrite(12,HIGH);
          }else if(tens==5){
            
    digitalWrite(10,HIGH);
    digitalWrite(12,HIGH);
            }else if(tens==4){
               digitalWrite(11,HIGH);
    digitalWrite(10,HIGH);
   
              }else if(tens==3){
                 digitalWrite(11,HIGH);
    digitalWrite(10,HIGH);
    digitalWrite(12,HIGH);
                }else if(tens==2){
                   digitalWrite(11,HIGH);
   
    digitalWrite(12,HIGH);
                  }else if(tens==1){
   digitalWrite(11,HIGH);
    digitalWrite(10,HIGH);
 
}

if(ones==9){
  digitalWrite(6,HIGH);
  digitalWrite(4,HIGH);
}else if(ones==8){
   digitalWrite(6,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(9,HIGH);
  digitalWrite(5,HIGH);
  
    }else if(ones==6){
      digitalWrite(6,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(9,HIGH);
  digitalWrite(5,HIGH);
      }else if(ones==5){
       digitalWrite(6,HIGH);
  digitalWrite(4,HIGH);
  
  digitalWrite(5,HIGH);
   
  
        }else if(ones==4){
          digitalWrite(6,HIGH);
  digitalWrite(4,HIGH);
  
   
          }else if(ones==3){
          
  digitalWrite(4,HIGH);
  
  digitalWrite(5,HIGH);
 
            }else if(ones==2){
              
 
  digitalWrite(4,HIGH);
 digitalWrite(9,HIGH);
  digitalWrite(5,HIGH);
             
                }else if(ones==0){
                   digitalWrite(6,HIGH);

  digitalWrite(9,HIGH);
  digitalWrite(5,HIGH);
                }
}
//-------------------------------------------------------------------------
//------------------------------------------------------------------
void RedFunction(){

  digitalWrite(18,LOW);  //set it to RED
  digitalWrite(19,HIGH);
  digitalWrite(7,LOW);      //set Colon : Low
  
  digitalWrite(13,LOW);        //set blues low
  digitalWrite(15,LOW);
  digitalWrite(16,LOW);
  digitalWrite(14,LOW);
  digitalWrite(12,LOW);
  digitalWrite(11,LOW);
  digitalWrite(10,LOW);
  digitalWrite(7,LOW);
  digitalWrite(5,LOW);
  digitalWrite(9,LOW);
  digitalWrite(6,LOW);
  digitalWrite(4,LOW);
  
  if (single==1){
  digitalWrite(17,HIGH);
    digitalWrite(16,HIGH);
  }
  if (minutes1==10){
    digitalWrite(17,HIGH);
    digitalWrite(16,HIGH);
   
    digitalWrite(13,HIGH);
      digitalWrite(14,HIGH);
        digitalWrite(15,HIGH);
        
  } else if (minutes1==9){
  digitalWrite(13,HIGH);
      digitalWrite(14,HIGH);
        digitalWrite(15,HIGH);
    } else if (minutes1==8){
      digitalWrite(13,HIGH);
      digitalWrite(14,HIGH);
        digitalWrite(15,HIGH);
      } else if (minutes1==7){
        digitalWrite(13,HIGH);
      digitalWrite(14,HIGH);
        digitalWrite(15,HIGH);
        } else if (minutes1==6){
          digitalWrite(13,HIGH);
      digitalWrite(14,HIGH);
       
          } else if (minutes1==5){
            digitalWrite(13,HIGH);
      digitalWrite(14,HIGH);
       
            } else if (minutes1==4){
           
      digitalWrite(14,HIGH);
        digitalWrite(15,HIGH);
              } else if (minutes1==3){
                digitalWrite(13,HIGH);
      digitalWrite(14,HIGH);
        digitalWrite(15,HIGH);
                } else if (minutes1==2){
                  digitalWrite(13,HIGH);
     
        digitalWrite(15,HIGH);
                  } else if (minutes1==1){
                    
      digitalWrite(14,HIGH);
        digitalWrite(15,HIGH);
  }
  if(tens==0){
    digitalWrite(9,HIGH);
     digitalWrite(10,HIGH);
     
      digitalWrite(12,HIGH);
  }else if(tens==9){
   
      digitalWrite(11,HIGH);
      digitalWrite(12,HIGH);
    }else if(tens==8){
      digitalWrite(9,HIGH);
     digitalWrite(10,HIGH);
      digitalWrite(11,HIGH);
      digitalWrite(12,HIGH);
      
        }else if(tens==6){
          digitalWrite(9,HIGH);
     digitalWrite(10,HIGH);
      digitalWrite(11,HIGH);
      digitalWrite(12,HIGH);
          }else if(tens==5){
          
     digitalWrite(10,HIGH);
      digitalWrite(11,HIGH);
      digitalWrite(12,HIGH);
            }else if(tens==4){
             
      digitalWrite(11,HIGH);
      digitalWrite(12,HIGH);
              }else if(tens==3){
             
     digitalWrite(10,HIGH);
      digitalWrite(11,HIGH);
     
                }else if(tens==2){
                  digitalWrite(9,HIGH);
     digitalWrite(10,HIGH);
      digitalWrite(11,HIGH);
      }
  
  if (ones==0){
    digitalWrite(6,HIGH);
    digitalWrite(4,HIGH);
    digitalWrite(5,HIGH);
  } else if (ones==9){
    digitalWrite(6,HIGH);
    digitalWrite(4,HIGH);
    digitalWrite(5,HIGH);
    
     } else if (ones==8){
      digitalWrite(6,HIGH);
    digitalWrite(4,HIGH);
    digitalWrite(5,HIGH);
        } else if (ones==7){
         digitalWrite(6,HIGH);
    
          
  There's no room for the rest of the code, but hopefully you get the gist