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
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
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.
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.
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:
The following table shows the circuit connections between the 7-segment module and the LPC2148
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++);
}
Previous article:CAN repeater design based on LPC2119 and μC/OSII
Next article:How to use ADC in ARM7-LPC2148
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Espressif releases new products really fast: the first Wi-Fi 6 + Bluetooth 5 (LE) RISC-V SoC is released
- November 10th prize-winning live broadcast: Protecting clean water sources - ADI water quality monitoring program registration is open~
- Thermal fatigue analysis of power modules
- FOC sensorless motor control video
- The differential voltage measured by the oscilloscope when the RS485 bus is idle is ±3.7V, and the periodic waveform with a frequency of 50hz
- Why would the filter added to the final stage cavity be burned?
- 【Beetle ESP32-C3】GNSS test
- Arteli AT32 uses GPIO to simulate HDMI CEC case
- Analyze the cause of tms320c6455 burning
- Beacon navigation sound positioning and recognition - microphone array