Riad_ Bajraktarevic
/
Joystick_Led
Aufgabe 1. BusOut Programm
main.cpp@3:e090a9b08c31, 2020-01-12 (annotated)
- Committer:
- riad
- Date:
- Sun Jan 12 12:30:46 2020 +0000
- Revision:
- 3:e090a9b08c31
- Parent:
- 2:ae17974ea4a6
int main; Joystick
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
riad | 0:c8ca3cbede43 | 1 | #include "mbed.h" |
riad | 0:c8ca3cbede43 | 2 | |
riad | 0:c8ca3cbede43 | 3 | BusOut lb(LED1,LED2,LED3,LED4); |
riad | 0:c8ca3cbede43 | 4 | DigitalIn joy(BUTTON1); |
riad | 1:15d8fa68d1ab | 5 | |
riad | 3:e090a9b08c31 | 6 | void lb1 (); |
riad | 3:e090a9b08c31 | 7 | |
riad | 3:e090a9b08c31 | 8 | int main () |
riad | 3:e090a9b08c31 | 9 | { |
riad | 3:e090a9b08c31 | 10 | while(1) |
riad | 3:e090a9b08c31 | 11 | { |
riad | 3:e090a9b08c31 | 12 | if(joy) |
riad | 3:e090a9b08c31 | 13 | { |
riad | 3:e090a9b08c31 | 14 | lb1 (); |
riad | 3:e090a9b08c31 | 15 | } |
riad | 3:e090a9b08c31 | 16 | wait_ms(100); |
riad | 3:e090a9b08c31 | 17 | } |
riad | 3:e090a9b08c31 | 18 | } |
riad | 1:15d8fa68d1ab | 19 | |
riad | 1:15d8fa68d1ab | 20 | void lb1 () |
riad | 1:15d8fa68d1ab | 21 | { |
riad | 1:15d8fa68d1ab | 22 | lb = 1; |
riad | 1:15d8fa68d1ab | 23 | wait_ms(100); |
riad | 1:15d8fa68d1ab | 24 | |
riad | 1:15d8fa68d1ab | 25 | for(int i = 0; i<=7; i++) |
riad | 1:15d8fa68d1ab | 26 | { |
riad | 1:15d8fa68d1ab | 27 | lb = lb << 1; |
riad | 1:15d8fa68d1ab | 28 | lb = lb | 1; |
riad | 1:15d8fa68d1ab | 29 | wait_ms(100); |
riad | 1:15d8fa68d1ab | 30 | } |
riad | 2:ae17974ea4a6 | 31 | |
riad | 2:ae17974ea4a6 | 32 | lb = 15; |
riad | 2:ae17974ea4a6 | 33 | wait_ms(100); |
riad | 2:ae17974ea4a6 | 34 | |
riad | 2:ae17974ea4a6 | 35 | for(int i = 0; i<=7; i++) |
riad | 2:ae17974ea4a6 | 36 | { |
riad | 2:ae17974ea4a6 | 37 | lb = lb >> 1; |
riad | 2:ae17974ea4a6 | 38 | lb = lb | 1; |
riad | 2:ae17974ea4a6 | 39 | wait_ms(100); |
riad | 2:ae17974ea4a6 | 40 | } |
riad | 1:15d8fa68d1ab | 41 | } |