Displays 4 bit binary count on bar graph display. Demonstrates BusOut usage.
Fork of Nightlight3 by
main.cpp@7:52ed5fbb1208, 2017-11-01 (annotated)
- Committer:
- CSTritt
- Date:
- Wed Nov 01 20:05:22 2017 +0000
- Revision:
- 7:52ed5fbb1208
- Parent:
- 6:0c1ab2c11252
- Child:
- 8:2be3e2339203
Changed misleading comment and reversed order of bus pins.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
CSTritt | 0:8ed2f4a2a2fe | 1 | /* |
CSTritt | 6:0c1ab2c11252 | 2 | Project: BinaryCount |
CSTritt | 0:8ed2f4a2a2fe | 3 | File: main.cpp |
CSTritt | 0:8ed2f4a2a2fe | 4 | |
CSTritt | 6:0c1ab2c11252 | 5 | Displays 4 bit binary count on bar graph display. |
CSTritt | 0:8ed2f4a2a2fe | 6 | |
CSTritt | 0:8ed2f4a2a2fe | 7 | Written by: Dr. C. S. Tritt |
CSTritt | 7:52ed5fbb1208 | 8 | Created: 9/13/17 (v. 1.1) |
CSTritt | 0:8ed2f4a2a2fe | 9 | */ |
CSTritt | 0:8ed2f4a2a2fe | 10 | #include "mbed.h" |
CSTritt | 0:8ed2f4a2a2fe | 11 | |
CSTritt | 7:52ed5fbb1208 | 12 | BusOut barGraph(D2, D3, D4, D5); // Create barGraph BusOut object. |
CSTritt | 6:0c1ab2c11252 | 13 | DigitalOut pinD7(D7); // Needed to force this pin off. |
CSTritt | 0:8ed2f4a2a2fe | 14 | |
CSTritt | 0:8ed2f4a2a2fe | 15 | int main() { |
CSTritt | 6:0c1ab2c11252 | 16 | |
CSTritt | 7:52ed5fbb1208 | 17 | printf("Binary Count Example\n"); // ID software. |
CSTritt | 0:8ed2f4a2a2fe | 18 | |
CSTritt | 7:52ed5fbb1208 | 19 | pinD7 = 0; // Force pin D7 off. |
CSTritt | 0:8ed2f4a2a2fe | 20 | |
CSTritt | 7:52ed5fbb1208 | 21 | barGraph = 0; // Start with all bars off. |
CSTritt | 0:8ed2f4a2a2fe | 22 | while(true) { |
CSTritt | 6:0c1ab2c11252 | 23 | barGraph = barGraph + 1; // Add one to count. |
CSTritt | 6:0c1ab2c11252 | 24 | wait(1.0); |
CSTritt | 6:0c1ab2c11252 | 25 | if (barGraph == 15) { |
CSTritt | 6:0c1ab2c11252 | 26 | barGraph = 0; |
CSTritt | 2:5682a72277ed | 27 | } |
CSTritt | 0:8ed2f4a2a2fe | 28 | } |
CSTritt | 4:aa100356f053 | 29 | } |