Wednesday 13 July 2016

How to Interface 7-Segment LED using 8 GPIO of Arduino Uno?

7-Segment Led Interfacing Using GPIOs
How many TV shows and movies have some mysterious device counting down to zero those displays are 7 segment displays.With the 7 segment displays you can display any number or some alphabets that your heart desires.

At first controlling a 7 segment display seems quite complex but it quickly becomes clear.

What follows is a quick guide to control a 7 segment display with a arduino board.
  • First let me do it on proteus simulator.


  • Arduino Code:

  1. void setup()
  2. {
  3.  int i=0;
  4.  for(i=0;i<8;i++) 
  5.  {
  6.    pinMode(i,OUTPUT);
  7.  }
  8. }
  9. void loop()
  10. {
  11.  char x=0x00;
  12.  PORTD = x;
  13.  x++;
  14.  delay(500);
  15. }
Common Configuration(Anod/Cathod)

This post is all about how to interface a seven segment display with microcontroller. In this particular example I will interface one seven segment display with PIC24. You may download Proteus Simulations and code from the links given at the bottom of this page.

  1.             I am using MPLAB X IDE and C30 Compiler for 16bit microcontrollers. I supposed that you know how to blink an LED (if not then I suggest you to read this (link) first before continuing this post) and how to generate a delay without timers or with timers ((if not then I suggest you to read this (link1 and Link2) first before continuing this post).

                There are two types of seven segments available in the market
    1)      Common anode.
    2)      Common cathode.

    I will go through from both of them in order to make you understand that what differences will be caused in hardware and software.

    In hardware they are arrange in following type:


    Common Anode Internal configuration.

    Truth table for Common Anode:


    Dp
    (MSB)
    G
    F
    E
    D
    C
    B
    A
    (LSB)
    Value in hex
    0
    1
    1
    0
    0
    0
    0
    0
    0
    0xC0
    1
    1
    1
    1
    1
    1
    0
    0
    1
    0xF9
    2
    1
    0
    1
    0
    0
    1
    0
    0
    0xA4
    3
    1
    0
    1
    1
    0
    0
    0
    0
    0xB0
    4
    1
    0
    0
    1
    1
    0
    0
    1
    0x99
    5
    1
    0
    0
    1
    0
    0
    1
    0
    0x92
    6
    1
    0
    0
    0
    0
    0
    1
    0
    0x82
    7
    1
    1
    1
    1
    1
    0
    0
    0
    0xF8
    8
    1
    0
    0
    0
    0
    0
    0
    0
    0x80
    9
    1
    0
    0
    1
    1
    0
    0
    0
    0x98


    Common Cathode Internal configuration.






    For Reference:


No comments:

Post a Comment

How to install google-chrome in redhat without redhat subscription

Install google-chrome in redhat  Download the .rpm file of chrome https://www.google.com/chrome/thank-you.html?installdataindex=empty&st...