Count patients as they enter and leave a waiting room. Not working due to button bounce.
Fork of ForLoopIteration by
main.cpp@0:9475544275a6, 2017-09-21 (annotated)
- Committer:
- CSTritt
- Date:
- Thu Sep 21 20:11:08 2017 +0000
- Revision:
- 0:9475544275a6
- Child:
- 1:0dc1ade9379d
My initial version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
CSTritt | 0:9475544275a6 | 1 | /* |
CSTritt | 0:9475544275a6 | 2 | Project: ForLoopIteration |
CSTritt | 0:9475544275a6 | 3 | File: main.cpp |
CSTritt | 0:9475544275a6 | 4 | |
CSTritt | 0:9475544275a6 | 5 | Demonstrates the use of a for() loop. Lights multiple LEDs in sequence, then |
CSTritt | 0:9475544275a6 | 6 | in reverse. |
CSTritt | 0:9475544275a6 | 7 | |
CSTritt | 0:9475544275a6 | 8 | The circuit: |
CSTritt | 0:9475544275a6 | 9 | |
CSTritt | 0:9475544275a6 | 10 | Bargraph LEDs from pins 2 through 11 to ground via 330 Ohm resistors. |
CSTritt | 0:9475544275a6 | 11 | |
CSTritt | 0:9475544275a6 | 12 | Created 2006 |
CSTritt | 0:9475544275a6 | 13 | by David A. Mellis |
CSTritt | 0:9475544275a6 | 14 | Modified 30 Aug 2011 |
CSTritt | 0:9475544275a6 | 15 | by Tom Igoe |
CSTritt | 0:9475544275a6 | 16 | Modified for Nucleo / mbed 12 Aug 2017 |
CSTritt | 0:9475544275a6 | 17 | by Sheila Ross |
CSTritt | 0:9475544275a6 | 18 | Modified by C. S. Tritt 9/21/17 (v. 1.0) |
CSTritt | 0:9475544275a6 | 19 | |
CSTritt | 0:9475544275a6 | 20 | This example code is in the public domain. |
CSTritt | 0:9475544275a6 | 21 | */ |
CSTritt | 0:9475544275a6 | 22 | |
CSTritt | 0:9475544275a6 | 23 | #include "mbed.h" |
CSTritt | 0:9475544275a6 | 24 | |
CSTritt | 0:9475544275a6 | 25 | float delay = 0.1; // Seconds, the higher the number, the slower the rate. |
CSTritt | 0:9475544275a6 | 26 | |
CSTritt | 0:9475544275a6 | 27 | BusOut bar_graph(D2,D3,D4,D5,D6,D7,D8,D9,D10,D11); |
CSTritt | 0:9475544275a6 | 28 | |
CSTritt | 0:9475544275a6 | 29 | int main() { |
CSTritt | 0:9475544275a6 | 30 | |
CSTritt | 0:9475544275a6 | 31 | while(true) { // Keep the lights going back and forth forever. |
CSTritt | 0:9475544275a6 | 32 | |
CSTritt | 0:9475544275a6 | 33 | // Lighted bar will shift from 0 to 9 places. |
CSTritt | 0:9475544275a6 | 34 | for(int shift = 0; shift < 10; shift++) { |
CSTritt | 0:9475544275a6 | 35 | bar_graph = (1<<shift); // A 1 shifted over "shift" places. |
CSTritt | 0:9475544275a6 | 36 | wait(delay); // Pause |
CSTritt | 0:9475544275a6 | 37 | } |
CSTritt | 0:9475544275a6 | 38 | |
CSTritt | 0:9475544275a6 | 39 | // Now shift down from 9 to 0 places. |
CSTritt | 0:9475544275a6 | 40 | for(int shift = 9; shift >= 0; shift--) { |
CSTritt | 0:9475544275a6 | 41 | bar_graph = (1 << shift); // A 1 shifted over "shift" places. |
CSTritt | 0:9475544275a6 | 42 | wait(delay); // Pause |
CSTritt | 0:9475544275a6 | 43 | } |
CSTritt | 0:9475544275a6 | 44 | } |
CSTritt | 0:9475544275a6 | 45 | } |