Arduino with seven segment display

This is part of the starter blog for Arduino basics. Check out here to see all of them.

A seven segment display has an array of seven LEDs in an ordered character like arrangement, so that when some of the LEDs glow, you can display any character or digit. It looks like this-

7-segment display

We need them to display values or characters and help in debugging when you use them in large projects.

Now they usually come in two arrangements – ‘common anode’ and ‘common cathode’. In common anode, all the positive terminals of the LEDs are connected to a common lead and in common cathode, all negative terminals of the LEDs are connected to a common lead.

common anode

The common anode is usually available in the market, so we are gonna use that. In case you have a common cathode one, don’t worry, you can simply edit the code and get it running. If you don’t now which one you have, check by lighting up a single segment using the 3.3v pin of the UNO.
So lets get started!

 

~What you need~

You will need the following parts. Your PC is also needed of course.

  1. Arduino UNO
  2. 7-segment display
  3. 1k resistor
  4. Breadboard
  5. Jumper wires

Following is an image of all the parts.

~What to do~

Now lets get down to the circuit. If you followed the above diagram of common anode configuration, the arrangement of pins in the seven segment is exactly like that. Lets go through the steps.

  1. Connect the pins A-B-C-D-E-F-G-DP to pins 1-2-3-4-5-6-7-8 respectively.
  2. Connect both pins Com to +5v. ( put com to gnd if you have common cathode)
  3. You may or may not add the resistor in series with the Com terminal. Resistor is added to ensure that you don’t burn the LEDs in the 7-segment display.

Below is the circuit diagram.

The following table shows the digits and their corresponding value in terms of common anode configuration. If you have a common cathode, simply replace all ‘1’s with ‘0’ and you are done!

Digitsabcdefgdp
110011110
200100100
300001100
410011000
501001000
601000000
700011110
800000000
900011000
000000010

Now we are going to display the digits from 1-9. Type the following code into the IDE and upload it.

Viola! you get a digital display!

Now, you can improve on the above project. Try the following.

  1. Try putting two displays side by side and display up-to digits 99!!
  2. Try displaying characters using the 7-segment display.

You can move on to other projects if you are done with this. Check out the following..

Feel free to ask any queries in the comment section below.

Arduino with seven segment display
Tagged on:                 

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: