![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
rter
Dependencies: BluetoothSerial SeeedShieldBot mbed
main.cpp@0:bf723d62720d, 2015-11-12 (annotated)
- Committer:
- simwiu
- Date:
- Thu Nov 12 09:06:01 2015 +0000
- Revision:
- 0:bf723d62720d
er
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simwiu | 0:bf723d62720d | 1 | #include "mbed.h" |
simwiu | 0:bf723d62720d | 2 | |
simwiu | 0:bf723d62720d | 3 | BusOut Leds (PA_9,PC_7,PB_6,PA_5,PB_5,PB_4); |
simwiu | 0:bf723d62720d | 4 | InterruptIn SW7 (PB_3); |
simwiu | 0:bf723d62720d | 5 | InterruptIn SW4 (PC_1); |
simwiu | 0:bf723d62720d | 6 | |
simwiu | 0:bf723d62720d | 7 | static int teller=0; |
simwiu | 0:bf723d62720d | 8 | |
simwiu | 0:bf723d62720d | 9 | void SW7_Pushed() |
simwiu | 0:bf723d62720d | 10 | { teller=teller+1; |
simwiu | 0:bf723d62720d | 11 | //Leds=~teller; |
simwiu | 0:bf723d62720d | 12 | } |
simwiu | 0:bf723d62720d | 13 | |
simwiu | 0:bf723d62720d | 14 | int main() |
simwiu | 0:bf723d62720d | 15 | { |
simwiu | 0:bf723d62720d | 16 | //Leds=~teller; |
simwiu | 0:bf723d62720d | 17 | SW7.fall(&SW7_Pushed); |
simwiu | 0:bf723d62720d | 18 | wait_ms(5); |
simwiu | 0:bf723d62720d | 19 | |
simwiu | 0:bf723d62720d | 20 | while (true) |
simwiu | 0:bf723d62720d | 21 | { |
simwiu | 0:bf723d62720d | 22 | SW4==1; |
simwiu | 0:bf723d62720d | 23 | |
simwiu | 0:bf723d62720d | 24 | teller=0; |
simwiu | 0:bf723d62720d | 25 | SW7.enable_irq(); |
simwiu | 0:bf723d62720d | 26 | wait_ms(1000); |
simwiu | 0:bf723d62720d | 27 | SW7.disable_irq(); |
simwiu | 0:bf723d62720d | 28 | |
simwiu | 0:bf723d62720d | 29 | if (teller >= 8) |
simwiu | 0:bf723d62720d | 30 | Leds=~0xFF; |
simwiu | 0:bf723d62720d | 31 | else if (teller >= 7) |
simwiu | 0:bf723d62720d | 32 | Leds=~0x7F; |
simwiu | 0:bf723d62720d | 33 | else if (teller >= 6) |
simwiu | 0:bf723d62720d | 34 | Leds=~0x3F; |
simwiu | 0:bf723d62720d | 35 | else if (teller >= 5) |
simwiu | 0:bf723d62720d | 36 | Leds=~0x1F; |
simwiu | 0:bf723d62720d | 37 | else if (teller >= 4) |
simwiu | 0:bf723d62720d | 38 | Leds=~0x0F; |
simwiu | 0:bf723d62720d | 39 | else if (teller >= 3) |
simwiu | 0:bf723d62720d | 40 | Leds=~0x07; |
simwiu | 0:bf723d62720d | 41 | else if (teller >= 2) |
simwiu | 0:bf723d62720d | 42 | Leds=~0x03; |
simwiu | 0:bf723d62720d | 43 | else if (teller >= 1) |
simwiu | 0:bf723d62720d | 44 | Leds=~0x01; |
simwiu | 0:bf723d62720d | 45 | else Leds=~0x00; |
simwiu | 0:bf723d62720d | 46 | |
simwiu | 0:bf723d62720d | 47 | |
simwiu | 0:bf723d62720d | 48 | |
simwiu | 0:bf723d62720d | 49 | } |
simwiu | 0:bf723d62720d | 50 | } |
simwiu | 0:bf723d62720d | 51 | |
simwiu | 0:bf723d62720d | 52 |