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

Revision:
1:46dbd77e0701
Parent:
0:463ff11d33fa
Child:
2:412c0b6f186c
--- a/main.cpp	Sat Dec 29 12:00:01 2012 +0000
+++ b/main.cpp	Sat Sep 03 17:36:47 2016 +0000
@@ -1,38 +1,92 @@
 #include "mbed.h"
 
-    //pins are sorted from upper left corner of the display to the lower right corner
-    //the display has a common cathode
-    //the display actally has 8 led's, the last one is a dot 
-DigitalOut led[8]={p18, p19, p17, p20, p16, p14, p15, p13};
+ /*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)
+The Common Cathode means that to turn on the segments of the 7-segment (including decimal point)
+you write a one to that segment.
+For this 4 digit display (LDQ-N524R1), each digit works backward--like its wired Common Anode so
+You write a ZERO to turn on the selected digit AND a ONE to turn off the digit.
+
+Pin Out wiring guide:(connect the display pin # to XX mbed pin)
 
+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, 
 
-    //each led that has to light up gets a 1, every other led gets a 0
-    //its in order of the DigitalOut Pins above
-int number[11][8]={
-                    {1,1,1,0,1,1,1,0},          //zero
-                    {0,0,1,0,0,1,0,0},          //one
-                    {1,0,1,1,1,0,1,0},          //two
-                    {1,0,1,1,0,1,1,0},          //three
-                    {0,1,1,1,0,1,0,0},          //four
-                    {1,1,0,1,0,1,1,0},          //five
-                    {1,1,0,1,1,1,1,0},          //six
-                    {1,0,1,0,0,1,0,0},          //seven
+Program demonstrates writing to one 7-segment display of 4 digit display LDQ-N514R1  
+Author: Cap'n Tim Johnson PE
+Retired Professor
+Wentworth Institude of Technology 
+Dept. Electrical Engineering and Technology
+Boston, MA
+*/
+
+//Setup:
+DigitalOut Digit1(p14);  //construct to control digits
+DigitalOut Digit2(p13);
+DigitalOut Digit3(p12);
+DigitalOut Digit4(p11);
+
+//these are the pins associated with writing to the "led"
+DigitalOut led[8]={p21, p22, p23, p24, p25, p26, p27, p10};
+
+//segments are in alphabetical order a-g, followed by Decimal point in the array below
+    
+int matrix[11][8]={
+                    {1,1,1,1,1,1,0,0},          //zero
+                    {0,1,1,0,0,0,0,0},          //one
+                    {1,1,0,1,1,0,1,0},          //two
+                    {1,1,1,1,0,0,1,0},          //three
+                    {0,1,1,0,0,1,1,0},          //four
+                    {1,0,1,1,0,1,1,0},          //five
+                    {1,0,1,1,1,1,1,0},          //six
+                    {1,1,1,0,0,0,0,0},          //seven
                     {1,1,1,1,1,1,1,0},          //eight
-                    {1,1,1,1,0,1,1,0},          //nine
+                    {1,1,1,0,0,1,1,0},          //nine
                     {0,0,0,0,0,0,0,1}          //dot
                   };
 
 
 int main() {
+    //DigitalOut (p14, 0); //Turn on digit#1, Most Significant Digit
+   
+    Digit1 = 1; //turn off digit1
+    Digit2 = 1; //turn off digit2
+    Digit3 = 1; //turn off digit3
+    Digit4 = 1; //turn off digit4
+
     while (1) {
+            //Digit1 = 0; //turn on digit1    
             //all led's off
-        for(int i = 0; i<8;i++){led[i] = 0;}
+        for(int i = 0; i<8;i++){
+            led[i] = 0;
+            }
         
-            //display shows the number in this case 6
-        for (int i=0; i<8; i++){led[i] = number[6][i];}         //the digit after "number" is displayed
-
-            //before it gets tired
-        wait(0.5);
+        //belows holds row of matrix and assign column value from matrix
+        for (int d=0; d<11; d++){
+            Digit1 = 0;             //turns on digit1
+            for (int i=0; i<8; i++){
+                led[i] = matrix[d][i];
+                }  
+            wait(0.5);
+            Digit1 = 1; //turn off digit1
+            wait(1);
+       }
+        wait(1);
     
     }
 }
\ No newline at end of file