Ben Trevett
/
Button_LED_K64
Press SW2 for red LED. Press SW3 for blue LED.
main.cpp@1:dfc1069a94f5, 2015-12-31 (annotated)
- Committer:
- bentrevett
- Date:
- Thu Dec 31 23:16:26 2015 +0000
- Revision:
- 1:dfc1069a94f5
- Parent:
- 0:b9aa0612f361
- Child:
- 2:381e5197a992
changed LED declaration
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bentrevett | 0:b9aa0612f361 | 1 | #include "mbed.h" |
bentrevett | 0:b9aa0612f361 | 2 | |
bentrevett | 1:dfc1069a94f5 | 3 | DigitalOut red(LED1); |
bentrevett | 0:b9aa0612f361 | 4 | DigitalOut blue(LED3); |
bentrevett | 0:b9aa0612f361 | 5 | DigitalIn sw2(PTC6); |
bentrevett | 0:b9aa0612f361 | 6 | InterruptIn sw3(PTA4); |
bentrevett | 0:b9aa0612f361 | 7 | |
bentrevett | 0:b9aa0612f361 | 8 | int main() |
bentrevett | 0:b9aa0612f361 | 9 | { |
bentrevett | 0:b9aa0612f361 | 10 | while(1) |
bentrevett | 0:b9aa0612f361 | 11 | { |
bentrevett | 0:b9aa0612f361 | 12 | blue=1; //turns LED off |
bentrevett | 0:b9aa0612f361 | 13 | red=1; |
bentrevett | 0:b9aa0612f361 | 14 | if(sw2==0) |
bentrevett | 0:b9aa0612f361 | 15 | { |
bentrevett | 0:b9aa0612f361 | 16 | red = 0; //turns LED on |
bentrevett | 0:b9aa0612f361 | 17 | } |
bentrevett | 0:b9aa0612f361 | 18 | if(sw3==0) |
bentrevett | 0:b9aa0612f361 | 19 | { |
bentrevett | 0:b9aa0612f361 | 20 | blue = 0; |
bentrevett | 0:b9aa0612f361 | 21 | } |
bentrevett | 0:b9aa0612f361 | 22 | } |
bentrevett | 0:b9aa0612f361 | 23 | } |