Understanding 7 segment display Displays

  • img
Project Details

The 7-segment is a very popular display we see on many electronic gadgets like digital clock, calculator, meters and many others. It’s a display that shows decimals and Hex. The display contains seven LEDs within a small rectangular shape. There are two types of 7-segment display called: Common Cathode (CC) and Common Anode (CA).

The Common Cathode means the LEDs within a segment has their entire negative terminal connected together while their positive terminals are separated. The opposite is the Common anode as all positive terminals are joined together internally while their negative terminals are separated.

In this project, we will learn how to display decimals on the segment display and also see how we can count from 0 to 9.

The sample code shows a simple way to write on segment using Ports to display only number 2.        

In our code, we loaded 01011011 into Port1 to display number 2, it shows that only pin a, b, d, e and g is selected high.

To write from 0 – 9 on the segment display just write your value on the segment with your desired time delay (in our project we will be using one second). You can copy the code below into your project and modify it anyhow you want it.

 

Code 

#include <CloudX\M633.h>
setup(){
//Setup here
portMode(1, 0b00000000);
loop(){
//Program here
portWrite(1,0b00111111); //0
delay(1000);
portWrite(1,0b00000110); //1
delay(1000);
portWrite(1,0b01011011); //2
delay(1000);
portWrite(1,0b01001111); //3
delay(1000);
portWrite(1,0b01100110); //4
delay(1000);
portWrite(1,0b01101101); //5
delay(1000);
portWrite(1,0b01011011); //6
delay(1000);
portWrite(1,0b00000111); //7
delay(1000);
portWrite(1,0b01111111); //8
delay(1000);
portWrite(1,0b01101111); //9
delay(1000);
}
}
 

Share this with friends