Arduino and 7 Segment LED Display Decoder




In this instructable i will explain how to connect 7 segment display, decoder and arduino. It´s pretty easy. At first we have to learn something about decoder. I´m using BCD to 7 segment decoder. My is D147D, this is old chip, but the newer are similar. Documentation about one of them you can find here . Description of D147D you can see on picture two. There are four pins for sending BCD code to the decoder (ABCD). Table of BCD code you can see on third picture. But there is small problem. I thing, that pins are inside of chip connected to VCC source. If you want set logic zero on input, you must connect this input to the ground.

The second think, which you need is display. You need display with common anode (+). There are a lot of displays, you can choose. Pinout of display which i used is on picture four(column A). How to connect decoder with display you can see in next step.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Connect It Together

On first picture you can see schematic. I think, that next pictures shows everything what you will need. On last picture is set prepared for testing. (picture was made in Fritzing)

Step 2: Add Arduino

Now connect four arduino pins on ABCD inputs of decoder. As I sad before logic 0 is on input, whem it isn,t connected to the ground. On arduino it means, that it is set logic 1(HIGH) on output of arduino. If you want set logic 1 on input of decoder, you need set 0(LOW) on arduino output. (picture was made in Fritzing)
Code can looks like this:

int inputs[4] = {17,14,15,16}; // A,B,C,D inputs
byte BCD[16][4] ={{0,0,0,0},
{1,1,1,1}}; //BCD code
int number = 5; //which number in BCD code do you want to send

void setup() {
for(int a = 0; a < 4; a++){
pinMode(inputs[a], OUTPUT);} //set outputs

void loop() {

for(int c = 0; c < 4; c++){
digitalWrite(inputs[c], BCD[number][c]);


Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    3 Discussions


    Question 7 months ago on Step 2

    hi man
    i working by arduino leonardo with 7seg cothod and 74ls48.
    when i conect arduino just 7segment on.. i cant display forexample 2
    help me please


    2 years ago

    Hi. I dont know about 7 segment displays, but the code you use to create a bcd output is long. I created a bcde (4 bit output) to drive a 1 to 16 decoder in 10 lines.

    for (int x=1; x<16; ++x) {

    int a=bitRead(x,0); // Reads the 1st bit of x, (ie 0 or 1)

    digitalWrite(pin, a); // Sets the 1st pin output to the logic (ie 0 or 1) of 1st bit

    int b=bitRead(x,1); // Reads 2nd bit of x, (0 or 1)

    digitalWrite(pin,b); // Sets 2nd pin output to the logic of 2nd bit

    int c=bitRead(x,2); // Reads 3rd bit of x

    digitalWrite(pin,c); // Sets pin 3rd pin to logic of bit 3

    intd=bitRead(x,3); // Reads 4th bit of x

    digitalWrite(pin,d); // Sets 4th pin to logic of 4th bit


    im sure theres a even shorter way, someone will come up with.

    1 reply

    Reply 1 year ago

    MacUKs The author’s code is, if you really need to measure, 9 lines, the matrix is one line, with wrapping. That is including setup() and loop() statements which you left out. Then again it’s pretty inane to argue something like that, but so is being compelled to go into someones instructable and proclaim his version sucks and that you’ve come up with something widely superior, especially when it’s not. The instructable isn’t even about the code, it’s about the principle, which was nicely made obvious by the statement that ”the code may look like this”

    And BTW, what your code does can be recreated in a oneliner, I’m sure you can figure it out if you put yout mind to it.