![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
k
Dependencies: mbed
main.cpp@0:f32d17a9423d, 2015-09-28 (annotated)
- Committer:
- TFuchsbichler
- Date:
- Mon Sep 28 13:42:05 2015 +0000
- Revision:
- 0:f32d17a9423d
lk
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
TFuchsbichler | 0:f32d17a9423d | 1 | #include "mbed.h" |
TFuchsbichler | 0:f32d17a9423d | 2 | |
TFuchsbichler | 0:f32d17a9423d | 3 | BusOut RGB(p23,p24,p25); |
TFuchsbichler | 0:f32d17a9423d | 4 | BusOut led(LED4,LED3,LED2,LED1); |
TFuchsbichler | 0:f32d17a9423d | 5 | |
TFuchsbichler | 0:f32d17a9423d | 6 | void red() |
TFuchsbichler | 0:f32d17a9423d | 7 | { |
TFuchsbichler | 0:f32d17a9423d | 8 | RGB=6; |
TFuchsbichler | 0:f32d17a9423d | 9 | } |
TFuchsbichler | 0:f32d17a9423d | 10 | |
TFuchsbichler | 0:f32d17a9423d | 11 | void green() |
TFuchsbichler | 0:f32d17a9423d | 12 | { |
TFuchsbichler | 0:f32d17a9423d | 13 | RGB=5; |
TFuchsbichler | 0:f32d17a9423d | 14 | } |
TFuchsbichler | 0:f32d17a9423d | 15 | |
TFuchsbichler | 0:f32d17a9423d | 16 | void yellow() |
TFuchsbichler | 0:f32d17a9423d | 17 | { |
TFuchsbichler | 0:f32d17a9423d | 18 | RGB=4; |
TFuchsbichler | 0:f32d17a9423d | 19 | } |
TFuchsbichler | 0:f32d17a9423d | 20 | |
TFuchsbichler | 0:f32d17a9423d | 21 | void black() |
TFuchsbichler | 0:f32d17a9423d | 22 | { |
TFuchsbichler | 0:f32d17a9423d | 23 | RGB=7; |
TFuchsbichler | 0:f32d17a9423d | 24 | } |
TFuchsbichler | 0:f32d17a9423d | 25 | |
TFuchsbichler | 0:f32d17a9423d | 26 | |
TFuchsbichler | 0:f32d17a9423d | 27 | |
TFuchsbichler | 0:f32d17a9423d | 28 | |
TFuchsbichler | 0:f32d17a9423d | 29 | int main() { |
TFuchsbichler | 0:f32d17a9423d | 30 | for(int i=1;i<=5;i++) |
TFuchsbichler | 0:f32d17a9423d | 31 | { |
TFuchsbichler | 0:f32d17a9423d | 32 | yellow(); |
TFuchsbichler | 0:f32d17a9423d | 33 | led=2; |
TFuchsbichler | 0:f32d17a9423d | 34 | wait_ms(250); |
TFuchsbichler | 0:f32d17a9423d | 35 | black(); |
TFuchsbichler | 0:f32d17a9423d | 36 | led=0; |
TFuchsbichler | 0:f32d17a9423d | 37 | wait_ms(250); |
TFuchsbichler | 0:f32d17a9423d | 38 | |
TFuchsbichler | 0:f32d17a9423d | 39 | |
TFuchsbichler | 0:f32d17a9423d | 40 | } |
TFuchsbichler | 0:f32d17a9423d | 41 | |
TFuchsbichler | 0:f32d17a9423d | 42 | while(1) |
TFuchsbichler | 0:f32d17a9423d | 43 | { |
TFuchsbichler | 0:f32d17a9423d | 44 | red(); |
TFuchsbichler | 0:f32d17a9423d | 45 | led=4; |
TFuchsbichler | 0:f32d17a9423d | 46 | wait_ms(10000); |
TFuchsbichler | 0:f32d17a9423d | 47 | yellow(); |
TFuchsbichler | 0:f32d17a9423d | 48 | led=6; |
TFuchsbichler | 0:f32d17a9423d | 49 | wait_ms(3000); |
TFuchsbichler | 0:f32d17a9423d | 50 | green(); |
TFuchsbichler | 0:f32d17a9423d | 51 | led=1; |
TFuchsbichler | 0:f32d17a9423d | 52 | wait_ms(8000); |
TFuchsbichler | 0:f32d17a9423d | 53 | |
TFuchsbichler | 0:f32d17a9423d | 54 | for(int i=1;i<=2;i++) |
TFuchsbichler | 0:f32d17a9423d | 55 | { |
TFuchsbichler | 0:f32d17a9423d | 56 | green(); |
TFuchsbichler | 0:f32d17a9423d | 57 | led=1; |
TFuchsbichler | 0:f32d17a9423d | 58 | wait_ms(250); |
TFuchsbichler | 0:f32d17a9423d | 59 | black(); |
TFuchsbichler | 0:f32d17a9423d | 60 | led=0; |
TFuchsbichler | 0:f32d17a9423d | 61 | wait_ms(250); |
TFuchsbichler | 0:f32d17a9423d | 62 | } |
TFuchsbichler | 0:f32d17a9423d | 63 | |
TFuchsbichler | 0:f32d17a9423d | 64 | yellow(); |
TFuchsbichler | 0:f32d17a9423d | 65 | led=2; |
TFuchsbichler | 0:f32d17a9423d | 66 | wait_ms(4000); |
TFuchsbichler | 0:f32d17a9423d | 67 | |
TFuchsbichler | 0:f32d17a9423d | 68 | } |
TFuchsbichler | 0:f32d17a9423d | 69 | } |