Page 154 - ARM Based Microcontroller Projects Using MBED
P. 154
140 8. INTERMEDIATE LEVEL PROJECTS
/***********************************************************************
2-DIGIT MULTIPLEXED LED
=======================
In this program a 2-digit 7-Segment LED is connected to PORT C of the
Nucleo-F411RE development board. The program displays the number 5 on
the display.
In this modified program leading 0 is disabled.
Author: Dogan Ibrahim
Date : August 2018
File : SevenSegMux3
************************************************************************/
#include "mbed.h"
PortOut Segments(PortC, 0xFF);
int LEDS[] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
DigitalOut MSDEnable(PC_8);
DigitalOut LSDEnable(PC_9);
#define Enable 1
#define Disable 0
int main()
{
int MSDValue, LSDValue, CNT;
CNT = 5; // Number to be displayed
MSDEnable = Disable; // Disable MSD digit
LSDEnable = Disable; // Disable LSD digit
while(1) // Do forever
{
MSDValue = CNT / 10; // MSD of the number
LSDValue = CNT % 10; // LSD of the number
if(MSDValue != 0) // If MSD value is not 0
{
Segments = LEDS[MSDValue]; // Send to PORT C
MSDEnable = Enable; // Enable MSD digit
wait(0.01); // Wait 10ms
MSDEnable = Disable; // Disable MSD digit
}
Segments = LEDS[LSDValue]; // Send to PORT C
LSDEnable = Enable; // Enable LSD digit
wait(0.01); // Wait 10ms
LSDEnable = Disable; // Disable LSD digit
}
}
FIG. 8.6 Modified program.