Interfacing 7-Segment Display With Shift Register Using CloudX Microcontroller

Introduction: Interfacing 7-Segment Display With Shift Register Using CloudX Microcontroller

In this project we are publishing a tutorial on how to interface seven segment LED display with CloudX microcontroller. Seven segment displays are used in many embedded system and industrial applications where the range of outputs to be shown is known beforehand. Basic 1 digit seven segment display can show numbers from 0-9 and a few characters. 7 segment displays are of different types; especially they differ in the number of digits/character it can display. Basically a 7 segment display is a single unit, which can display only 1 digit or 1 character. More digits are displayed by multiplexing single unit 7 segment displays together to form 2 digit display, 3 digit display or 4 digit 7 segment display. Its quiet easy to interface CloudX and 7 Segment display together! Lets begin the tutorial.

Step 1: HC595 Shift Register

74HC595

The 74HC595 consists of an 8−bit shift register and a storage register with three−state parallel outputs. It converts serial input into parallel output so that you can save IO ports of an MCU. The 74HC595 is widely used to indicate multipath LEDs and drive multi-bit segment displays. "Three-state" refers to the fact that you can set the output pins as either high, low or "high impedance." With data latching, the instant output will not be affected during the shifting; with data output, you can cascade 74HC595s more easily. Pins of 74HC595 and their functions: Q0-Q7: 8-bit parallel data output pins, able to control 8 LEDs or 8 pins of 7-segment display directly. Q7’: Series output pin, connected to DS of another 74HC595 to connect multiple 74HC595s in series MR: Reset pin, active at low level; here it is directly connected to 5V. SH: Time sequence input of shift register. On the rising edge, the data in shift register moves successively one bit, i.e. data in Q1 moves to Q2, and so forth. While on the falling edge, the data in shift register remain unchanged. ST: Time sequence input of storage register. On the rising edge, data in the shift register moves into memory register. OE : Output enable pin, active at low level, connected to GND. Ds : Serial data input pin VCC: Positive supply voltage GND: Ground Here the shiftout() function is used, which comes with the CloudX IDE. Simply input a number between 0 and 255 and the storage register can convert it into an 8-bit binary number and output it in parallel. This allows you to easily control the 8 pins of the 7-segment display and create any patterns you want.

Step 2: 7 SEGMENT

Let’s begin the tutorial. We are going to use CloudX M633 and a basic seven segment display with decimal point. You can identify the segments of the display with the help of figure above.

This seven segment display has a total of 8 LEDs per digit as shown in above image, seven LED’s for each segment and one for the decimal point.

As you can see there are 10 pins in total. You may notice two pins named com, as shown in the circuit diagram all the cathode (- pins) of the LEDs are connected to these two pins. We call these 2 pins as common cathodes and such displays are called Common Cathode 7 segment displays. There are some seven segment displays which have common anodes instead of common cathode. The only difference for common anode displays is all the anodes (+ pins) are connected together and they are known as Common Anode 7 segment displays. Apart from these 2 com pins, there are 8 other pins named A,B,C,D,E,F,G and DP. As you can see in the figure, these pins are anodes (+ pins) of the led segments of common cathode display (in the case of common anodes display these pins will be cathodes)

Step 3: Component Needed

  • CloudX M633
  • CloudX SoftCard
  • V3 Usb Cable
  • HC595 Shift register
  • jumper wires
  • Breadboard
  • 7 Segment display
  • 330 ohm resistor

Step 4: SETUP

Connect the 7-Segment display and 74HC595 shift register to CloudX M633:

Connect Vcc pin on 74HC595 to 5V pin on CloudX.

Connect GND and OE pins on 74HC595 to GND pin on CloudX.

Connect DS or SER pin on 74HC595 to digital pin 2 on CloudX.

Connect SHCP or SRCLK pin on 74HC595 to digital pin 1 on CloudX.

Connect STCP or RCLK pin on 74HC595 to digital pin 3 on CloudX.

Connect Q0-Q6 or QA-QG pin on 74HC595 to pin A-G on 7-segment display.

Connect Q7 or QH pin on 74HC595 to pin DP on 7-segment display.

Connect common cathode pins (pin 3 and 8 on the diagram) on 7-segment display to Gnd pin on CloudX.

Step 5: Code

#include <CloudX/M633.h>
#include <CloudX/74HC595.h>
ChangeValue(unsigned char value){
    switch(value){
            case 0:   return 0x3f;
            case 1:   return 0x06;
            case 2:   return 0x5b;
            case 3:   return 0x4f;
            case 4:   return 0x66;
            case 5:   return 0x6d;
            case 6:   return 0x7d;
            case 7:   return 0x07;
            case 8:   return 0x7f;
            case 9:   return 0x6f;
                  }
}
setup(){
        HC595_setting(2,1,3);
loop(){
        for(char i=0; i<10; i++){
        HC595_shiftOut(ChangeValue(i) , MSBFIRST );
        HC595_latch();
        delayMs(1000);
        }
}
}

Share

    Recommendations

    • Creative Misuse Contest

      Creative Misuse Contest
    • Tiny Home Contest

      Tiny Home Contest
    • Metalworking Contest

      Metalworking Contest

    Discussions