Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- captaintim
- Date:
- 2016-08-16
- Revision:
- 1:0e26c8d5e834
- Parent:
- 0:e3b48fea2164
- Child:
- 2:afd0cb53867f
- Child:
- 3:9affc00dfa25
File content as of revision 1:0e26c8d5e834:
#include "mbed.h"
/*comments: testing turning on and off of Pins for 7-segment diode
using https://developer.mbed.org/users/synvox/notebook/lpc1768-pinout-with-labelled-mbed-pins/
by Nenad Milosevic
verification: put the black lead of a multimeter on pin 1 (gnd)
and put the red lead on pin 26, voltage varies between +3.28VDC and 0VDC */
/*test program to learn how to write code for a 4 digit, 7-segment LED display LDQ-N524R1
The schematic for this (COMMON CATHODE) display shows the following connections
schematic located at http://www.lumex.com/ldq-n514ri (open Specs PDF for drawing)
Pin Out wiring guide:(connect these mbed pins to display)
CONTROL DISPLAY Pin# MBED Pin#
----------------------------------
Digit1 12 14
Digit2 9 13
Digit3 8 12
Digit4 6 11
DP 3 10
A 11 21
B 7 22
C 4 23
D 2 24
E 1 25
F 5 26
G 5 27
There is no blanking on this display,
you have to write a ONE to Gnd pin for specific digit to turn it off
Program demonstrates use of DigitalOut to control segments of 7 segment display for 4 digit display LDQ-N514R1
Author: Cap'n Tim Johnson PE
Retired Professor
Wentworth Institude of Technology
Dept. Electrical Engineering and Technology
Boston, MA
*/
DigitalOut myled(LED1); //used to signal where in the program "thou art".
int main() {
//int on = 1;
//int off = 0;
int i = 2; //wait time interval
//test of LED 7-segment diodes on 4 digit display
//while(1){
DigitalOut (p14, 0); //Turn on digit1, Most Significant Digit
DigitalOut (p21, 1);
DigitalOut (p22, 1);
DigitalOut (p23, 1);
DigitalOut (p24, 1);
DigitalOut (p25, 1);
DigitalOut (p26, 1);
DigitalOut (p27, 1);
DigitalOut (p10, 1); //decimal point
wait (i);
DigitalOut (p14, 1); //turn off digit1
DigitalOut (p13, 0); //turn on digit2
DigitalOut (p21, 1);
DigitalOut (p22, 1);
DigitalOut (p23, 1);
DigitalOut (p24, 1);
DigitalOut (p25, 1);
DigitalOut (p26, 1);
DigitalOut (p27, 1);
DigitalOut (p10, 1); //decimal point
wait (i);
DigitalOut (p13, 1); //turn off digit2
DigitalOut (p12, 0); //turn on digit3
DigitalOut (p21, 1);
DigitalOut (p22, 1);
DigitalOut (p23, 1);
DigitalOut (p24, 1);
DigitalOut (p25, 1);
DigitalOut (p26, 1);
DigitalOut (p27, 1);
DigitalOut (p10, 1); //decimal point
wait (i);
DigitalOut (p12, 1); //turn off digit3
DigitalOut (p11, 0); //turn on digit4, Least Significant Digit
DigitalOut (p21, 1);
DigitalOut (p22, 1);
DigitalOut (p23, 1);
DigitalOut (p24, 1);
DigitalOut (p25, 1);
DigitalOut (p26, 1);
DigitalOut (p27, 1);
DigitalOut (p10, 1); //decimal point
wait (i);
DigitalOut (p11, 1); //Turn off digit4
//they are all off
wait (1);
myled=1; //Signals all are about to turn on
wait (1);
DigitalOut (p14, 0); //Turn them all on
DigitalOut (p13, 0);
DigitalOut (p12, 0);
DigitalOut (p11, 0);
wait (i);
DigitalOut (p14, 1); //Turn them all off
DigitalOut (p13, 1);
DigitalOut (p12, 1);
DigitalOut (p11, 1);
wait (1);
DigitalOut (p14, 0); //Turn them all on as zeros
DigitalOut (p13, 0);
DigitalOut (p12, 0);
DigitalOut (p11, 0);
DigitalOut (p27, 0);
wait (i);
DigitalOut (p14, 1); //Turn them all off
DigitalOut (p13, 1);
DigitalOut (p12, 1);
DigitalOut (p11, 1);
wait (1);
DigitalOut (p14, 0); //Turn them all on as sevens
DigitalOut (p13, 0);
DigitalOut (p12, 0);
DigitalOut (p11, 0);
DigitalOut (p24, 0);
DigitalOut (p25, 0);
DigitalOut (p26, 0);
DigitalOut (p27, 0);
wait (i);
DigitalOut (p14, 1); //Turn them all off
DigitalOut (p13, 1);
DigitalOut (p12, 1);
DigitalOut (p11, 1);
wait (1);
myled=0; //end of program signal
}