Allows a sequence of numbers to display on a single digit of a 4 digit, 7 segment LED Display: LDQ-N514R1 by Lumex
Fork of 7SegmentDisplay by
main.cpp@0:463ff11d33fa, 2012-12-29 (annotated)
- Committer:
- ShingyoujiPai
- Date:
- Sat Dec 29 12:00:01 2012 +0000
- Revision:
- 0:463ff11d33fa
- Child:
- 1:46dbd77e0701
7 Segment Display Basic
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ShingyoujiPai | 0:463ff11d33fa | 1 | #include "mbed.h" |
ShingyoujiPai | 0:463ff11d33fa | 2 | |
ShingyoujiPai | 0:463ff11d33fa | 3 | //pins are sorted from upper left corner of the display to the lower right corner |
ShingyoujiPai | 0:463ff11d33fa | 4 | //the display has a common cathode |
ShingyoujiPai | 0:463ff11d33fa | 5 | //the display actally has 8 led's, the last one is a dot |
ShingyoujiPai | 0:463ff11d33fa | 6 | DigitalOut led[8]={p18, p19, p17, p20, p16, p14, p15, p13}; |
ShingyoujiPai | 0:463ff11d33fa | 7 | |
ShingyoujiPai | 0:463ff11d33fa | 8 | |
ShingyoujiPai | 0:463ff11d33fa | 9 | //each led that has to light up gets a 1, every other led gets a 0 |
ShingyoujiPai | 0:463ff11d33fa | 10 | //its in order of the DigitalOut Pins above |
ShingyoujiPai | 0:463ff11d33fa | 11 | int number[11][8]={ |
ShingyoujiPai | 0:463ff11d33fa | 12 | {1,1,1,0,1,1,1,0}, //zero |
ShingyoujiPai | 0:463ff11d33fa | 13 | {0,0,1,0,0,1,0,0}, //one |
ShingyoujiPai | 0:463ff11d33fa | 14 | {1,0,1,1,1,0,1,0}, //two |
ShingyoujiPai | 0:463ff11d33fa | 15 | {1,0,1,1,0,1,1,0}, //three |
ShingyoujiPai | 0:463ff11d33fa | 16 | {0,1,1,1,0,1,0,0}, //four |
ShingyoujiPai | 0:463ff11d33fa | 17 | {1,1,0,1,0,1,1,0}, //five |
ShingyoujiPai | 0:463ff11d33fa | 18 | {1,1,0,1,1,1,1,0}, //six |
ShingyoujiPai | 0:463ff11d33fa | 19 | {1,0,1,0,0,1,0,0}, //seven |
ShingyoujiPai | 0:463ff11d33fa | 20 | {1,1,1,1,1,1,1,0}, //eight |
ShingyoujiPai | 0:463ff11d33fa | 21 | {1,1,1,1,0,1,1,0}, //nine |
ShingyoujiPai | 0:463ff11d33fa | 22 | {0,0,0,0,0,0,0,1} //dot |
ShingyoujiPai | 0:463ff11d33fa | 23 | }; |
ShingyoujiPai | 0:463ff11d33fa | 24 | |
ShingyoujiPai | 0:463ff11d33fa | 25 | |
ShingyoujiPai | 0:463ff11d33fa | 26 | int main() { |
ShingyoujiPai | 0:463ff11d33fa | 27 | while (1) { |
ShingyoujiPai | 0:463ff11d33fa | 28 | //all led's off |
ShingyoujiPai | 0:463ff11d33fa | 29 | for(int i = 0; i<8;i++){led[i] = 0;} |
ShingyoujiPai | 0:463ff11d33fa | 30 | |
ShingyoujiPai | 0:463ff11d33fa | 31 | //display shows the number in this case 6 |
ShingyoujiPai | 0:463ff11d33fa | 32 | for (int i=0; i<8; i++){led[i] = number[6][i];} //the digit after "number" is displayed |
ShingyoujiPai | 0:463ff11d33fa | 33 | |
ShingyoujiPai | 0:463ff11d33fa | 34 | //before it gets tired |
ShingyoujiPai | 0:463ff11d33fa | 35 | wait(0.5); |
ShingyoujiPai | 0:463ff11d33fa | 36 | |
ShingyoujiPai | 0:463ff11d33fa | 37 | } |
ShingyoujiPai | 0:463ff11d33fa | 38 | } |