Tutorial on connecting a 7-segment display using ARM7-LPC2148

Publisher:码字奇思Latest update time:2023-02-09 Source: elecfansKeywords:ARM7  LPC2148 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Display is a very important part of any embedded system application as it helps the user understand the status of the system and displays the output or any warning messages generated by the system. There are many types of displays used in electronic products, such as 7-segment displays, LCD displays, TFT touch screen displays, LED displays, etc.


Today in this tutorial, we will connect a 7-segment display using ARM7-LPC2148. Before going into details, we will see how to control the 7-segment module to display any number of characters.


7 segment display

poYBAGNbhfqAeokFAABu9N5jRpY922.jpg

The 7-segment display is one of the simplest display units for displaying numbers and characters. It is often used to display numbers and has brighter lighting and a simpler structure than dot matrix displays. Since the illumination is brighter, the output can be viewed from a greater distance than an LCD. As shown in the figure above, the 7-segment display consists of 8 LEDs, each LED is used to illuminate one segment of the unit, and the 8th LED is used to illuminate the DOT in the 7-segment display. When using two or more 7-segment modules, for example for display (0.1), the 8thLED is used. A single module is used to display a single number or character. To display multiple numbers or characters, use multiple 7 segments.


7 segment display pins

There are 10 pins, 8 of which are used to represent a, b, c, d, e, f, g and h/dp, the middle two pins are the common anode/cathode for all LEDs. These common anode/cathode are shorted internally so we only need to connect one COM pin

poYBAGNbhfuAe2sOAAAWC9KsOAg446.gif

Based on the connections, we divide the 7 segments into two types:

common cathode

Among them, all the negative terminals (cathode) of all 8 LEDs are connected together (see picture below), named COM. All positives are placed individually or connected to microcontroller pins. If we use a microcontroller, we set the logic high to illuminate specific content and low to turn off the LED.


Ordinary anode

In it, all positive terminals (anodes) of all 8 LEDs are connected together, called COM. All negative heat is placed individually or connected to microcontroller pins. If we use a microcontroller we set the logic low to light up the specific and set the logic high to turn off the LED.

pYYBAGNbhfyAHHYdAAAaF8HOazY857.png

So depending on the pin value, a specific segment or row of 7 segments can be turned on or off to display the desired number or letter. For example, to display 0 digits we have to set pin ABCDEF high and only G low. Since the ABCDEF LED is on and the G LED is off, a 0-digit number is formed in the 7-segment module. (This is for a common cathode, for a common anode it is the opposite).


The table below shows the HEX values ​​and corresponding numbers according to the LPC2148 pins, for common cathode configuration.

pYYBAGNbhZaAcNlFAAB5yzM0jmk121.png

IMPORTANT NOTE: In the table above I have given the hexadecimal values ​​based on the pins used in the LPC2148, please see the circuit diagram below. You can use any pin you want, but the hex value will change based on that pin.


materials needed

hardware

Interrupter 2148

Seven-segment display module (single digits)

breadboard

Connecting line

software

Kyle Uwison 5

glitter magic

Circuit diagram

In order to interface the 7-segment with the LPC2148, no external components are required as shown in the picture below:

pYYBAGNbhf6Ab3gQAACL5F7w1R0409.png

The following table shows the circuit connections between the 7-segment module and the LPC2148

pYYBAGNbhauAaCHRAAAzS-mIls4137.png

poYBAGNbhgCAaTy9AACi2SUWpuQ825.jpg

Programming the ARM7 LPC2148

In the previous tutorial, we have learned how to program the ARM7-LPC2148 using Keil. We use the same Keil uVision 5 here to write the code and create the hex file, then use the Flash Magic tool to upload the hex file to the LPC2148. We use the USB cable for power and upload the code to the LPC2148

The complete code with video instructions is given at the end of this tutorial. Here we explain several important parts of the code.


First, we need to include the header files for the LPC214x series microcontrollers

#include

Next set the pin as output

IO0DIR=IO0DIR|0xffffffff

This will set pin P0.0 to P0.31 as output, but we will only use pins (P0.0, P0.1, P0.4, P0.5, P0.6, P0.7 and P0. 8).

Then set certain pins to logic high or low depending on the number you want to display. Here we will display the values ​​from (0 to 9). We will use an array consisting of HEX values ​​ranging from 0 to 9.

unsigned int a[]={0xf3,0x12,0x163,0x133,0x192,0x1b1,0x1f1,0x13,0x1f3,0x1b3};

The values ​​will be displayed continuously when the code is placed in the while loop

while(1)

{

for(i=0;i<=9;i++)

{

IO0SET=IO0SET|a[i]; //sets corresponding pins HIGH

delay(9000); //Calls delay function

IO0CLR=IO0CLR|a[i]; //Sets corresponding pins LOW

}

}

Here, IOSET and IOCRR are used to set the pin high and low respectively. Since we used the port 0 pin, we have IO0SET and IO0CLR.

The For loop is used to increment i on each iteration, and each time i is incremented, the 7 segment will also increment the number displayed on it.

Delay function is used to generate delay time between SET and CLR

void delay(int k) //Function for making delay

{

int i,j;

for(i=0;i

for(j=0;j<=1000;j++);

}
Full code

//INTERFACING SINGLE SEVEN SEGMENT MODULE WITH LPC2148

//CIRCUIT DIGEST

//By Pramoth.T


#include //Header file for LPC214x Series microcontrollers

void delay(int ); //Function declaration for delay

int i; //Variable declared as integer

unsigned int a[]={0xf3,0x12,0x163,0x133,0x192,0x1b1,0x1f1,0x13,0x1f3,0x1b3}; //integer array with numbers for display

int main()

{

IO0DIR=IO0DIR|0xffffffff; //Sets direction as output for PORT 0 pins

while(1)

{

for(i=0;i<=9;i++)

{

IO0SET=IO0SET|a[i]; //sets corresponding pins HIGH

delay(9000); //Calls delay function

IO0CLR=IO0CLR|a[i]; //Sets corresponding pins LOW

}

}

return 0;

}


void delay(int k) //Function for making delay

{

int i,j;

for(i=0;i
for(j=0;j<=1000;j++);

}


Keywords:ARM7  LPC2148 Reference address:Tutorial on connecting a 7-segment display using ARM7-LPC2148

Previous article:CAN repeater design based on LPC2119 and μC/OSII
Next article:How to use ADC in ARM7-LPC2148

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号