Introduction: Programming a Single 7 Segment Display

About: We bring hardware products to life, specializing in engineering, prototyping, and mass manufacturing. We've worked with over 20 Kickstarter projects.

This tutorial will introduce you to a 7 segment display and show you how to display a number (0 - 9) on a single 7 segment display. We see these displays every day and rarely think about how they work. These displays can be found on your digital alarm clock, elevator numbers, gas station price changer signs, stove tops, and on microwave oven display screens.

Here is a list of items we will need for this tutorial...

Hardware:

  • Arduino Uno
  • A to B USB cable
  • 10 Jumper wires
  • Breadboard
  • 1 single 7 segment

Software:

  • Arduino IDE software

The first thing we must understand is how to identify and turn on 1 segment of a 7 segment display. On the back side of the display, we notice 10 pins. If you need to review how to identify each of these 10 pins with their respective letters on the display (A through G) you might want to reference our last tutorial (What is a 7 Segment display? And how do they work?).

Insert the single digit 7 segment into the breadboard (be sure to allow room for your jumper wires).

Step 1:

Insert the single digit 7 segment into the breadboard (be sure to allow room for your jumper wires).

Step 2:

Select any digital pin on your Arduino Uno (we choose digital pin 2 on the board), and assign it to PIN1 (Letter E) on the segment.

Step 3:

Continue until all pins on the 7 segment are connected to their respected pins. Since we started with pin 2 on the Arduino Uno, we felt it would be easy to continue with pins 3 through 9 respectively.

Step 4:

Remember pins 3 & 8 are ground. The rest are control signals (5V since we have a common cathode segment). Connect the Arduino Uno to the computer, using the A to B USB cable and open the Arduino IDE software. Go to Tools > Serial Port and make sure you have selected the proper serial port. Go to Tools > Board and make sure you have selected the Arduino Uno. Now it's time to for the code: You can copy the code I've developed below (feel free to play with and edit this code). If you prefer, go ahead and enter your own code.

Step 5: Here Is the Code:

Click here to view the code for this project.

Step 6: Note About the Code:

Line 1 to Line 7: We chose to use "int" to store our values. Of course, we could have used a different variable, but we are comfortable with "int". Read more about "int" (http://arduino.cc/en/Reference/Int). Line 8 to Line 17: We choose to use hex format, you could have chosen binary, or decimal format.

Step 7: