Sep 212014
 

I got myself a cheap 4 digits 7-led display and I thought I would spend a few mns playing with it and documenting it.

4digits

 

12 pins : 8 for the segments (including the dots), 4 for each digit
Top row : 1, a, f, 2, 3, b
Bottomw row: e, d, dp, c, g, 4

I decided to use the Sevseg arduino library.
More about this library here.

The wiring is then as is :

Arduino pins -> 4digits display pins
2->1
6->a
11->f
3->2
4->3
7->b
10->e
9->d
13->dp
8->c
12->g
5->4

Below the schema

4digits_bb

Note that this is a lot of digital IO’s used. A future article could focus on reducing the number of IO’s needed.
Below the arduino sketch (from the example provided with the sevseg library)

/*Written by Dean Reading, 2012.  deanreading@hotmail.com
 
 This example is a centi-second counter to demonstrate the
 use of my SevSeg library.
 */

#include "SevSeg.h"

//Create an instance of the object.
SevSeg sevseg;

//Create global variables
unsigned long timer;
int CentSec=0;

void setup() {
  //I am using a common anode display, with the digit pins connected
  //from 2-5 and the segment pins connected from 6-13
  sevseg.Begin(1,2,3,4,5,6,7,8,9,10,11,12,13);
  //Set the desired brightness (0 to 100);
  sevseg.Brightness(50);

  timer=millis();
}

void loop() {
  //Produce an output on the display
  sevseg.PrintOutput();

  //Check if 10ms has elapsed
  unsigned long mils=millis();
  if (mils-timer>=10) {
    timer=mils;
    CentSec++;
    if (CentSec==10000) { // Reset to 0 after counting for 100 seconds.
      CentSec=0;
    }
    //Update the number to be displayed, with a decimal
    //place in the correct position.
    sevseg.NewNum(CentSec,(byte) 2);
  }
}
 Posted by at 18 h 08 min

9
Poster un Commentaire

avatar
3 Fils de commentaires
6 Réponses de fil
0 Abonnés
 
Commentaire avec le plus de réactions
Le plus populaire des commentaires
4 Auteurs du commentaire
GuyOduderadminjose Auteurs de commentaires récents
  S’abonner  
plus récent plus ancien
Notifier de
jose
Invité
jose

Hi !!!

Be so kind to explain how to reduce the number of I / O pins?

Greetings and thanks in advance.

duder
Invité
duder

I would love to use the SevSeg Library with a shift register for the 7 segments plus decimal point. I think you would have to modify SevSeg.cpp

Any luck?

GuyO
Invité
GuyO

In the code we can see that you use common anode display. I found that with common anode the resistor should be on the cathode. Can you explain/justify why you put resistors on anode. How did you calculate resistor value (330ohms) ?