Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@0:67efb4657416, 2016-08-17 (annotated)
- Committer:
- jplunkett
- Date:
- Wed Aug 17 01:46:59 2016 +0000
- Revision:
- 0:67efb4657416
- Child:
- 1:1aca092ceb7e
init
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jplunkett | 0:67efb4657416 | 1 | #include "mbed.h" |
| jplunkett | 0:67efb4657416 | 2 | #include "LED_Bar.h" |
| jplunkett | 0:67efb4657416 | 3 | |
| jplunkett | 0:67efb4657416 | 4 | LED_Bar bar(D6, D5); |
| jplunkett | 0:67efb4657416 | 5 | DigitalIn button1(A3); |
| jplunkett | 0:67efb4657416 | 6 | DigitalIn button2(A2); |
| jplunkett | 0:67efb4657416 | 7 | DigitalIn button3(A1); |
| jplunkett | 0:67efb4657416 | 8 | DigitalIn button4(A0); |
| jplunkett | 0:67efb4657416 | 9 | int button_index; |
| jplunkett | 0:67efb4657416 | 10 | |
| jplunkett | 0:67efb4657416 | 11 | int main() { |
| jplunkett | 0:67efb4657416 | 12 | bar.setLevel(0); |
| jplunkett | 0:67efb4657416 | 13 | while(1) { |
| jplunkett | 0:67efb4657416 | 14 | wait(0.3); |
| jplunkett | 0:67efb4657416 | 15 | if (button1) { |
| jplunkett | 0:67efb4657416 | 16 | button_index = 1; |
| jplunkett | 0:67efb4657416 | 17 | while(button1){ |
| jplunkett | 0:67efb4657416 | 18 | bar.setSingleLed(9, 1); |
| jplunkett | 0:67efb4657416 | 19 | bar.setSingleLed(8, 1); |
| jplunkett | 0:67efb4657416 | 20 | }; |
| jplunkett | 0:67efb4657416 | 21 | bar.setSingleLed(9, 0); |
| jplunkett | 0:67efb4657416 | 22 | bar.setSingleLed(8, 0); |
| jplunkett | 0:67efb4657416 | 23 | } |
| jplunkett | 0:67efb4657416 | 24 | if (button2) { |
| jplunkett | 0:67efb4657416 | 25 | button_index = 2; |
| jplunkett | 0:67efb4657416 | 26 | while(button2){ |
| jplunkett | 0:67efb4657416 | 27 | bar.setSingleLed(7, 1); |
| jplunkett | 0:67efb4657416 | 28 | bar.setSingleLed(6, 1); |
| jplunkett | 0:67efb4657416 | 29 | }; |
| jplunkett | 0:67efb4657416 | 30 | bar.setSingleLed(7, 0); |
| jplunkett | 0:67efb4657416 | 31 | bar.setSingleLed(6, 0); |
| jplunkett | 0:67efb4657416 | 32 | } |
| jplunkett | 0:67efb4657416 | 33 | if (button3) { |
| jplunkett | 0:67efb4657416 | 34 | button_index = 3; |
| jplunkett | 0:67efb4657416 | 35 | while(button3){ |
| jplunkett | 0:67efb4657416 | 36 | bar.setSingleLed(5, 1); |
| jplunkett | 0:67efb4657416 | 37 | bar.setSingleLed(4, 1); |
| jplunkett | 0:67efb4657416 | 38 | }; |
| jplunkett | 0:67efb4657416 | 39 | bar.setSingleLed(5, 0); |
| jplunkett | 0:67efb4657416 | 40 | bar.setSingleLed(4, 0); |
| jplunkett | 0:67efb4657416 | 41 | } |
| jplunkett | 0:67efb4657416 | 42 | if (button4) { |
| jplunkett | 0:67efb4657416 | 43 | button_index = 4; |
| jplunkett | 0:67efb4657416 | 44 | while(button4){ |
| jplunkett | 0:67efb4657416 | 45 | bar.setSingleLed(3, 1); |
| jplunkett | 0:67efb4657416 | 46 | bar.setSingleLed(2, 1); |
| jplunkett | 0:67efb4657416 | 47 | }; |
| jplunkett | 0:67efb4657416 | 48 | bar.setSingleLed(3, 0); |
| jplunkett | 0:67efb4657416 | 49 | bar.setSingleLed(2, 0); |
| jplunkett | 0:67efb4657416 | 50 | } |
| jplunkett | 0:67efb4657416 | 51 | } |
| jplunkett | 0:67efb4657416 | 52 | } |