Charles Tritt
/
21_7SegLU_v5
Introduces arrays by using a lookup table to control a 7-segment display.
main.cpp@110:1381af961a47, 2021-10-02 (annotated)
- Committer:
- CSTritt
- Date:
- Sat Oct 02 21:26:37 2021 +0000
- Revision:
- 110:1381af961a47
- Parent:
- 108:eee3167b25b4
Updated to 2017 program updated to Mbed v5.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
CSTritt | 107:61b9c99a4e27 | 1 | /* |
CSTritt | 110:1381af961a47 | 2 | Project: 21_7SegLU_v5 |
CSTritt | 108:eee3167b25b4 | 3 | File: main.cpp |
CSTritt | 110:1381af961a47 | 4 | |
CSTritt | 110:1381af961a47 | 5 | Counts through the digits 0 to 9 then DP on the 7-segment display. |
CSTritt | 108:eee3167b25b4 | 6 | |
CSTritt | 110:1381af961a47 | 7 | See external documentation for pin connections (very important). |
CSTritt | 110:1381af961a47 | 8 | |
CSTritt | 108:eee3167b25b4 | 9 | Written by: Dr. C. S. Tritt |
CSTritt | 110:1381af961a47 | 10 | Created: 10/2/21 (v. 1.2) |
CSTritt | 107:61b9c99a4e27 | 11 | */ |
Jonathan Austin |
0:2757d7abb7d9 | 12 | #include "mbed.h" |
CSTritt | 108:eee3167b25b4 | 13 | |
CSTritt | 110:1381af961a47 | 14 | BusOut ssDisplay(D3, D4, D5, D6, D7, D8, D9, D10); // Segments, LSB to MSB. |
CSTritt | 108:eee3167b25b4 | 15 | |
CSTritt | 108:eee3167b25b4 | 16 | int main() { |
CSTritt | 110:1381af961a47 | 17 | // Declare and initialize array in one step. |
CSTritt | 110:1381af961a47 | 18 | const int Segments[] |
CSTritt | 110:1381af961a47 | 19 | {0x81, 0xCF, 0x92, 0x86, 0xCC, 0xA4, 0xA0, 0x8F, 0x80, 0x84, 0x7F}; |
CSTritt | 110:1381af961a47 | 20 | |
CSTritt | 110:1381af961a47 | 21 | while(true) { // Loop forever. |
CSTritt | 110:1381af961a47 | 22 | for (int i = 0; i <= 10; i++) { // Cycle through digits. |
CSTritt | 110:1381af961a47 | 23 | ssDisplay = Segments[i]; // Display current digit. |
CSTritt | 110:1381af961a47 | 24 | ThisThread::sleep_for(1000); // Wait a second, then repeat. |
CSTritt | 108:eee3167b25b4 | 25 | } |
CSTritt | 108:eee3167b25b4 | 26 | } |
CSTritt | 108:eee3167b25b4 | 27 | } |