≡ Menu

* This is a multi-part post. Here are links to all parts:

Part 1: Intro, bill of materials and simple sketch
Part 2: The 2-digit 7-segment display circuit; this post
Part 3: Sketch broken down in sections, explained
Part 4: Added two buttons, and modified sketch
Part 5: Code for buttons, explained

This week we’ll look at the circuit for the 2-digit 7-segment display counter using the Arduino.

There are a few options to control multiple displays:

  • employing multiple controllers;
  • using a 7-segment driver chip like the 7447;
  • using a multi-display controller such as the MAXIM MAX7219;
  • sequencing through the displays, which is what we have done in our example, as it requires no added hardware.

When we were using a single-digit display, we connected the common anode pin to our Vdd supply, but with two digits we have to drive them independently if we want them to display different digits!

[continue reading…]

{ 12 comments }
2-digit 7-segment display

* 2-Digit 7-segment display counter is a multi-part post. Here are links to all parts:

Part 1: Intro, bill of materials and simple sketch; this post
Part 2: The circuit for the 2-digit 7-segment display counter
Part 3: Sketch broken down in sections, explained
Part 4: Added two buttons, and modified sketch
Part 5: Code for buttons, explained

This month’s Arduino project is to build two 2-digit 7-segment display circuits and sketches, one that counts up and one that counts up using mini push buttons. The next posts will explain the circuits and the Arduino sketches. (Here’s a simpler, 1-digit 7-segment display using Arduino).

Materials:

Sketch for the 2-digit 7-segment display counter (without buttons):
[continue reading…]

{ 49 comments }

The Arduino is based on the microcontrollers from Atmel. Here are current Arduinos available (the architecture is open source, and anyone can build their own “Arduino” based on the technical specs that are available for download from the official Arduino website).

  • Duemilanove: “Duemilanove” means 2009 in Italian and is named after the year of its release. The Duemilanove is the latest in a series of USB Arduino boards. It is based on the ATmega328 and has 14 digital input/output pins (of which 6 can be used as PWM outputs) and 6 analog inputs.
  • MEGA: The Arduino Mega is based on the ATmega1280. It has 54 digital input/output pins (of which 14 can be used as PWM outputs) and 16 analog inputs.

[continue reading…]

{ 0 comments }
TGIMBOEJ

The Great Internet Migratory Box Of Electronics Junk

TGIMBOEJ, The Great Internet Migratory Box Of Electronics Junk is a progressive lending repository of electronic components. An open collaborative project, TGIMBOEJ can be seen as a cross between P2P file sharing and a flea market, an internet meme in physical form. It arrives full of wonderful (and possibly useless) components, but you will surely find some treasures to keep. You will be inspired to look through your own stuff and find more “electronic junk” that can be donated to the box before it is passed on again. And on and on and on. There are several incarnations of TGIMBOEJ being passed around the US and some parts of the world.
[continue reading…]

{ 0 comments }

* This is a multi-part post. Here are links to all parts:

Part 1: Overview
Part 2: Bill of Materials and sketch #1
Part 3: Sketch #2, using a pushbutton
Part 4: Sketch #3, bit manipulation; this post

The third and final Arduino sketch uses bits to represent each segment and is a reduced code version of the previous sketch (1,210 bytes for sketch #3 instead of 1,852 bytes for sketch #2). A ten element array holds a byte for each number 0-9 that specifies what segments should be lit (pin low). Bit 0 corresponds to segment A, bit 1 to segment B and so on. In order to display the number 1, segments B and C need to be lit, so that is represented by the value 0b1111001. Function “lightSegments” reads these bits in sequence and sets the corresponding segments accordingly.

[continue reading…]

{ 19 comments }
Seven segment display with Arduino

* This is a multi-part post. Here are links to all parts:

Part 1: Overview
Part 2: Bill of Materials and sketch #1
Part 3: Sketch #2, using a pushbutton; this post
Part 4: Sketch #3, bit manipulation

The second sketch cycles through the numbers from 0 to 9, but only increments the display counter each time a button is pressed. Note that this code includes simple debouncing by introducing a short delay when the Arduino detects that the button has been pressed.

Sketch #2:

// www.TinkerHobby.com
// Natalia Fargasch Norman
// Seven-segment LED Display
// Common Anode pins 3 and 8

//   G F + A B
//   | | | | |   -> pins and segments they control
//   ---------
//  F|   A   |B
//   |---G---|   -> segments
//  E|   D   |C
//   ---------
//   | | | | |   -> pins and segments they control
//   E D + C DP

// Segments that make each number when lit:
// 0 => ABCDEF
// 1 => BC
// 2 => ABDEG
// 3 => ABCDG
// 4 => BCFG
// 5 => ACDFG
// 6 => ACDEFG
// 7 => ABC
// 8 => ABCDEFG
// 9 => ABCDFG

// Arduino digital pins used to light up
// corresponding segments on the LED display
#define A 2
#define B 3
#define C 4
#define D 5
#define E 6
#define F_SEG 7
#define G 8

// Pushbutton connected to pin 9
#define BUTTON 9

// Common anode;
// on when pin is low
// and off when pin is high
#define ON LOW
#define OFF HIGH

int count = 0; // current display count
int val = 0;   // digital input from button

void setup() {
  pinMode(A, OUTPUT);
  pinMode(B, OUTPUT);
  pinMode(C, OUTPUT);
  pinMode(D, OUTPUT);
  pinMode(E, OUTPUT);
  pinMode(F_SEG, OUTPUT);
  pinMode(G, OUTPUT);
  pinMode(BUTTON, INPUT);
  zero();
}

void loop() {
  val = digitalRead(BUTTON);
  if (val == HIGH) {
    count++;
    delay(200);
    switch (count) {
      case 0:
        zero();
        break;
      case 1:
        one();
        break;
      case 2:
        two();
        break;
      case 3:
        three();
        break;
      case 4:
        four();
        break;
      case 5:
        five();
        break;
      case 6:
        six();
        break;
      case 7:
        seven();
        break;
      case 8:
        eight();
        break;
      case 9: {
        nine();
        count = -1;
        break;
      }
    }
  }
}

// 0 => ABCDEF
void zero() {
  digitalWrite(A, ON);
  digitalWrite(B, ON);
  digitalWrite(C, ON);
  digitalWrite(D, ON);
  digitalWrite(E, ON);
  digitalWrite(F_SEG, ON);
  digitalWrite(G, OFF);
}

// 1 => BC
void one() {
  digitalWrite(A, OFF);
  digitalWrite(B, ON);
  digitalWrite(C, ON);
  digitalWrite(D, OFF);
  digitalWrite(E, OFF);
  digitalWrite(F_SEG, OFF);
  digitalWrite(G, OFF);
}

// 2 => ABDEG
void two() {
  digitalWrite(A, ON);
  digitalWrite(B, ON);
  digitalWrite(C, OFF);
  digitalWrite(D, ON);
  digitalWrite(E, ON);
  digitalWrite(F_SEG, OFF);
  digitalWrite(G, ON);
}

// 3 => ABCDG
void three() {
  digitalWrite(A, ON);
  digitalWrite(B, ON);
  digitalWrite(C, ON);
  digitalWrite(D, ON);
  digitalWrite(E, OFF);
  digitalWrite(F_SEG, OFF);
  digitalWrite(G, ON);
}

// 4 => BCFG
void four() {
  digitalWrite(A, OFF);
  digitalWrite(B, ON);
  digitalWrite(C, ON);
  digitalWrite(D, OFF);
  digitalWrite(E, OFF);
  digitalWrite(F_SEG, ON);
  digitalWrite(G, ON);
}

// 5 => ACDFG
void five() {
  digitalWrite(A, ON);
  digitalWrite(B, OFF);
  digitalWrite(C, ON);
  digitalWrite(D, ON);
  digitalWrite(E, OFF);
  digitalWrite(F_SEG, ON);
  digitalWrite(G, ON);
}

// 6 => ACDEFG
void six() {
  digitalWrite(A, ON);
  digitalWrite(B, OFF);
  digitalWrite(C, ON);
  digitalWrite(D, ON);
  digitalWrite(E, ON);
  digitalWrite(F_SEG, ON);
  digitalWrite(G, ON);
}

// 7 => ABC
void seven() {
  digitalWrite(A, ON);
  digitalWrite(B, ON);
  digitalWrite(C, ON);
  digitalWrite(D, OFF);
  digitalWrite(E, OFF);
  digitalWrite(F_SEG, OFF);
  digitalWrite(G, OFF);
}

// 8 => ABCDEFG
void eight() {
  digitalWrite(A, ON);
  digitalWrite(B, ON);
  digitalWrite(C, ON);
  digitalWrite(D, ON);
  digitalWrite(E, ON);
  digitalWrite(F_SEG, ON);
  digitalWrite(G, ON);
}

// 9 => ABCDFG
void nine() {
  digitalWrite(A, ON);
  digitalWrite(B, ON);
  digitalWrite(C, ON);
  digitalWrite(D, ON);
  digitalWrite(E, OFF);
  digitalWrite(F_SEG, ON);
  digitalWrite(G, ON);
}
{ 15 comments }