Allows a sequence of numbers to display on a single digit of a 4 digit, 7 segment LED Display: LDQ-N514R1 by Lumex

Dependencies:   mbed

Fork of 7SegmentDisplay by Svend Kaffke

Committer:
captaintim
Date:
Sat Sep 03 17:36:47 2016 +0000
Revision:
1:46dbd77e0701
Parent:
0:463ff11d33fa
Child:
2:412c0b6f186c
Revised 7SegmentDisplay program found in mbed community to display a number sequence on the LDQ-N514R1 4 digit, 7Segment LED Display

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ShingyoujiPai 0:463ff11d33fa 1 #include "mbed.h"
ShingyoujiPai 0:463ff11d33fa 2
captaintim 1:46dbd77e0701 3 /*test program to learn how to write code for a 4 digit, 7-segment LED display LDQ-N524R1
captaintim 1:46dbd77e0701 4 The schematic for this (COMMON CATHODE) display shows the following connections
captaintim 1:46dbd77e0701 5 schematic located at http://www.lumex.com/ldq-n514ri (open Specs PDF for drawing)
captaintim 1:46dbd77e0701 6 The Common Cathode means that to turn on the segments of the 7-segment (including decimal point)
captaintim 1:46dbd77e0701 7 you write a one to that segment.
captaintim 1:46dbd77e0701 8 For this 4 digit display (LDQ-N524R1), each digit works backward--like its wired Common Anode so
captaintim 1:46dbd77e0701 9 You write a ZERO to turn on the selected digit AND a ONE to turn off the digit.
captaintim 1:46dbd77e0701 10
captaintim 1:46dbd77e0701 11 Pin Out wiring guide:(connect the display pin # to XX mbed pin)
ShingyoujiPai 0:463ff11d33fa 12
captaintim 1:46dbd77e0701 13 CONTROL DISPLAY Pin# MBED Pin#
captaintim 1:46dbd77e0701 14 ----------------------------------
captaintim 1:46dbd77e0701 15 Digit1 12 14
captaintim 1:46dbd77e0701 16 Digit2 9 13
captaintim 1:46dbd77e0701 17 Digit3 8 12
captaintim 1:46dbd77e0701 18 Digit4 6 11
captaintim 1:46dbd77e0701 19 DP 3 10
captaintim 1:46dbd77e0701 20 A 11 21
captaintim 1:46dbd77e0701 21 B 7 22
captaintim 1:46dbd77e0701 22 C 4 23
captaintim 1:46dbd77e0701 23 D 2 24
captaintim 1:46dbd77e0701 24 E 1 25
captaintim 1:46dbd77e0701 25 F 5 26
captaintim 1:46dbd77e0701 26 G 5 27
captaintim 1:46dbd77e0701 27
captaintim 1:46dbd77e0701 28 There is no blanking on this display,
ShingyoujiPai 0:463ff11d33fa 29
captaintim 1:46dbd77e0701 30 Program demonstrates writing to one 7-segment display of 4 digit display LDQ-N514R1
captaintim 1:46dbd77e0701 31 Author: Cap'n Tim Johnson PE
captaintim 1:46dbd77e0701 32 Retired Professor
captaintim 1:46dbd77e0701 33 Wentworth Institude of Technology
captaintim 1:46dbd77e0701 34 Dept. Electrical Engineering and Technology
captaintim 1:46dbd77e0701 35 Boston, MA
captaintim 1:46dbd77e0701 36 */
captaintim 1:46dbd77e0701 37
captaintim 1:46dbd77e0701 38 //Setup:
captaintim 1:46dbd77e0701 39 DigitalOut Digit1(p14); //construct to control digits
captaintim 1:46dbd77e0701 40 DigitalOut Digit2(p13);
captaintim 1:46dbd77e0701 41 DigitalOut Digit3(p12);
captaintim 1:46dbd77e0701 42 DigitalOut Digit4(p11);
captaintim 1:46dbd77e0701 43
captaintim 1:46dbd77e0701 44 //these are the pins associated with writing to the "led"
captaintim 1:46dbd77e0701 45 DigitalOut led[8]={p21, p22, p23, p24, p25, p26, p27, p10};
captaintim 1:46dbd77e0701 46
captaintim 1:46dbd77e0701 47 //segments are in alphabetical order a-g, followed by Decimal point in the array below
captaintim 1:46dbd77e0701 48
captaintim 1:46dbd77e0701 49 int matrix[11][8]={
captaintim 1:46dbd77e0701 50 {1,1,1,1,1,1,0,0}, //zero
captaintim 1:46dbd77e0701 51 {0,1,1,0,0,0,0,0}, //one
captaintim 1:46dbd77e0701 52 {1,1,0,1,1,0,1,0}, //two
captaintim 1:46dbd77e0701 53 {1,1,1,1,0,0,1,0}, //three
captaintim 1:46dbd77e0701 54 {0,1,1,0,0,1,1,0}, //four
captaintim 1:46dbd77e0701 55 {1,0,1,1,0,1,1,0}, //five
captaintim 1:46dbd77e0701 56 {1,0,1,1,1,1,1,0}, //six
captaintim 1:46dbd77e0701 57 {1,1,1,0,0,0,0,0}, //seven
ShingyoujiPai 0:463ff11d33fa 58 {1,1,1,1,1,1,1,0}, //eight
captaintim 1:46dbd77e0701 59 {1,1,1,0,0,1,1,0}, //nine
ShingyoujiPai 0:463ff11d33fa 60 {0,0,0,0,0,0,0,1} //dot
ShingyoujiPai 0:463ff11d33fa 61 };
ShingyoujiPai 0:463ff11d33fa 62
ShingyoujiPai 0:463ff11d33fa 63
ShingyoujiPai 0:463ff11d33fa 64 int main() {
captaintim 1:46dbd77e0701 65 //DigitalOut (p14, 0); //Turn on digit#1, Most Significant Digit
captaintim 1:46dbd77e0701 66
captaintim 1:46dbd77e0701 67 Digit1 = 1; //turn off digit1
captaintim 1:46dbd77e0701 68 Digit2 = 1; //turn off digit2
captaintim 1:46dbd77e0701 69 Digit3 = 1; //turn off digit3
captaintim 1:46dbd77e0701 70 Digit4 = 1; //turn off digit4
captaintim 1:46dbd77e0701 71
ShingyoujiPai 0:463ff11d33fa 72 while (1) {
captaintim 1:46dbd77e0701 73 //Digit1 = 0; //turn on digit1
ShingyoujiPai 0:463ff11d33fa 74 //all led's off
captaintim 1:46dbd77e0701 75 for(int i = 0; i<8;i++){
captaintim 1:46dbd77e0701 76 led[i] = 0;
captaintim 1:46dbd77e0701 77 }
ShingyoujiPai 0:463ff11d33fa 78
captaintim 1:46dbd77e0701 79 //belows holds row of matrix and assign column value from matrix
captaintim 1:46dbd77e0701 80 for (int d=0; d<11; d++){
captaintim 1:46dbd77e0701 81 Digit1 = 0; //turns on digit1
captaintim 1:46dbd77e0701 82 for (int i=0; i<8; i++){
captaintim 1:46dbd77e0701 83 led[i] = matrix[d][i];
captaintim 1:46dbd77e0701 84 }
captaintim 1:46dbd77e0701 85 wait(0.5);
captaintim 1:46dbd77e0701 86 Digit1 = 1; //turn off digit1
captaintim 1:46dbd77e0701 87 wait(1);
captaintim 1:46dbd77e0701 88 }
captaintim 1:46dbd77e0701 89 wait(1);
ShingyoujiPai 0:463ff11d33fa 90
ShingyoujiPai 0:463ff11d33fa 91 }
ShingyoujiPai 0:463ff11d33fa 92 }