Testet die RGB
Dependencies: mbed
main.cpp@1:727c55ba9d9f, 2015-06-15 (annotated)
- Committer:
- winkler_martin
- Date:
- Mon Jun 15 18:25:59 2015 +0000
- Revision:
- 1:727c55ba9d9f
- Parent:
- 0:28a4d412f331
RBG led...
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lukas__27 | 0:28a4d412f331 | 1 | #include "mbed.h" |
lukas__27 | 0:28a4d412f331 | 2 | |
lukas__27 | 0:28a4d412f331 | 3 | PwmOut ledblue (p25); |
lukas__27 | 0:28a4d412f331 | 4 | PwmOut ledgreen (p26); |
lukas__27 | 0:28a4d412f331 | 5 | PwmOut ledred (p14); |
lukas__27 | 0:28a4d412f331 | 6 | int main() |
lukas__27 | 0:28a4d412f331 | 7 | { |
lukas__27 | 0:28a4d412f331 | 8 | //double max = 170; |
lukas__27 | 0:28a4d412f331 | 9 | double red = 255; |
lukas__27 | 0:28a4d412f331 | 10 | double green = 0; |
lukas__27 | 0:28a4d412f331 | 11 | double blue = 0; |
lukas__27 | 0:28a4d412f331 | 12 | ledblue = 1; |
lukas__27 | 0:28a4d412f331 | 13 | ledred = (100 - red)/100; |
lukas__27 | 0:28a4d412f331 | 14 | ledgreen = 1; |
lukas__27 | 0:28a4d412f331 | 15 | double time = 0.1; |
lukas__27 | 0:28a4d412f331 | 16 | while(1) { |
lukas__27 | 0:28a4d412f331 | 17 | |
lukas__27 | 0:28a4d412f331 | 18 | while(green <= 255) { |
winkler_martin | 1:727c55ba9d9f | 19 | green = green + 5; |
lukas__27 | 0:28a4d412f331 | 20 | ledgreen = (100 - green)/100; |
lukas__27 | 0:28a4d412f331 | 21 | wait(time); |
lukas__27 | 0:28a4d412f331 | 22 | } |
lukas__27 | 0:28a4d412f331 | 23 | while(red >= 0) { |
winkler_martin | 1:727c55ba9d9f | 24 | red = red - 5; |
lukas__27 | 0:28a4d412f331 | 25 | ledred = (100 - red)/100; |
lukas__27 | 0:28a4d412f331 | 26 | wait(time); |
lukas__27 | 0:28a4d412f331 | 27 | } |
lukas__27 | 0:28a4d412f331 | 28 | while(blue <= 255) { |
winkler_martin | 1:727c55ba9d9f | 29 | blue = blue + 5; |
lukas__27 | 0:28a4d412f331 | 30 | ledblue = (100 - blue)/100; |
lukas__27 | 0:28a4d412f331 | 31 | wait(time); |
lukas__27 | 0:28a4d412f331 | 32 | } |
lukas__27 | 0:28a4d412f331 | 33 | while(green >= 0) { |
winkler_martin | 1:727c55ba9d9f | 34 | green = green - 5; |
lukas__27 | 0:28a4d412f331 | 35 | ledgreen = (100 - green)/100; |
lukas__27 | 0:28a4d412f331 | 36 | wait(time); |
lukas__27 | 0:28a4d412f331 | 37 | } |
lukas__27 | 0:28a4d412f331 | 38 | while(red <= 255) { |
winkler_martin | 1:727c55ba9d9f | 39 | red = red + 5; |
lukas__27 | 0:28a4d412f331 | 40 | ledred = (100 - red)/100; |
lukas__27 | 0:28a4d412f331 | 41 | wait(time); |
lukas__27 | 0:28a4d412f331 | 42 | } |
lukas__27 | 0:28a4d412f331 | 43 | while(blue >= 0) { |
lukas__27 | 0:28a4d412f331 | 44 | blue = blue - 1; |
lukas__27 | 0:28a4d412f331 | 45 | ledblue = (100 - blue)/100; |
lukas__27 | 0:28a4d412f331 | 46 | wait(time); |
lukas__27 | 0:28a4d412f331 | 47 | |
lukas__27 | 0:28a4d412f331 | 48 | } |
lukas__27 | 0:28a4d412f331 | 49 | } |
lukas__27 | 0:28a4d412f331 | 50 | } |