PSoC Lab 02: 4-Digit Seven Segment Display
Objective
- Learn how to interface 4-digit seven-segment display
- Learn proper configuration of the Segment LCD component
Required Reading Material
Background Information
A 4-digit seven-segment display has 12 pins; 8 of the pins are for the 8 LEDs on each of the seven-segment displays, which includes A ~ G and DP (decimal point). The other 4 pins represent each of the 4 digits from D1 ~ D4. The pinout for the 4-digit seven-segment display is shown below.
Figure 1: The Pinout for 4-Digit Seven-Segment Display
Required Components List
![]() |
4-Digit Seven Segment Display | x 1 |
![]() |
Push Button | x 1 |
![]() |
Resistor: 220 ohm | x 8 |
Circuit / Schematic Diagram
Procedure
Check Lists
FIll the following configuration information into the report
- Port.Pin configuration:
Device Port.Pin Signal Type Direction: Drive Mode
TopDesign and PSoC Components
Add the following PSoC Creator components in the TopDesign:
Figure 1: TopDesign.cysch
- Display ➤
4 Digit 7-Segment LED Driver
- Ports and Pins ➤
Digital Input Pin
Sample Code
main.c
#include "project.h" #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <stdbool.h> int main(void) { uint16_t count = 0; CyGlobalIntEnable; /* Enable global interrupts. */ /* Place your initialization/startup code here (e.g. MyInst_Start()) */ LED_Start(); LED_Write7SegNumberDec(count, 0, 4, LED_RIGHT_ALIGN); for(;;) { /* Place your application code here. */ if (!nSW_Read()){ count++; LED_Write7SegNumberDec(count, 0, 4, LED_RIGHT_ALIGN); // Display a number from com0 for 4 digits CyDelay(250); } } }
When you press and hold the SW, the system will count up from 0 to 9999. When you release SW, the system will stop counting.
Questions
- What type of seven-segment display that you used in this lab? Common Anode (CA) or Common Cathode (CC)? How to identify it without using a multimeter and search from datasheet or internet?
- What number will be displayed on the 4-digit seven-segment LCD for the following code?
uint32_t count32 = 123456;
LED_Write7SegNumberDec(count32, 0, 4, LED_RIGHT_ALIGN);
Exercises