A small project: Single digit counter with a seven-segments Led Display

image

Display pins:

LTS_4301JR_2

 

ToGo_7Seg_Wiring

Ready to download the Sketch:

Conexions

A working counter…

20131026_120615

The Sketch used:

/*ToGo_7Seg.ino
Arduining.com 26 OCT 2013
Driving the LTS-4301JR Common Cathode 7 Segments Display.
Using the Freetronics ELEVEN
*/

//Pins connections to segments: 
#define  segA   5
#define  segB   4
#define  segC   3
#define  segD   10
#define  segE   11
#define  segF   12
#define  segG   13
#define  segDP  2

//Array with the segments to represent the decimal numbers (0-9).
byte segments[10] = {
// pgfedcba  <--- segments
  B00111111, // number 0
  B00000110, // number 1
  B01011011, // number 2
  B01001111, // number 3
  B01100110, // number 4
  B01101101, // number 5
  B01111101, // number 6
  B00000111, // number 7
  B01111111, // number 8
  B01101111  // number 9
};

void setup(){

  pinMode(segA,OUTPUT);
  pinMode(segB,OUTPUT);
  pinMode(segC,OUTPUT);
  pinMode(segD,OUTPUT);
  pinMode(segE,OUTPUT);
  pinMode(segF,OUTPUT);
  pinMode(segG,OUTPUT);
  pinMode(segDP,OUTPUT);

}

//================================================================
void loop(){
  for(int i=0;i<10;i++){
  Display(i);

    delay(2000);
  }
}

/*-------------------------------------------------------------------
Put the segments according to the number.
--------------------------------------------------------------------*/
void Display(int number){
byte segs = segments[number]; 

digitalWrite(segA, bitRead(segs, 0) );
digitalWrite(segB, bitRead(segs, 1) );
digitalWrite(segC, bitRead(segs, 2) );
digitalWrite(segD, bitRead(segs, 3) );
digitalWrite(segE, bitRead(segs, 4) );
digitalWrite(segF, bitRead(segs, 5) );
digitalWrite(segG, bitRead(segs, 6) );
}

How to add a small breadboard to the freetronics ELEVEN:

ArdTogo

Will be nice to have a recessed zone near the USB connector to use the clam shell as board support.

20130725_111451

 

Advertisements