teapLED
Dependencies: PololuLedStrip mbed
color.h@0:84c4f17abdc1, 2017-09-01 (annotated)
- Committer:
- tanabe2000
- Date:
- Fri Sep 01 02:18:12 2017 +0000
- Revision:
- 0:84c4f17abdc1
teapLED
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tanabe2000 | 0:84c4f17abdc1 | 1 | #include "mbed.h" |
tanabe2000 | 0:84c4f17abdc1 | 2 | #include "PololuLedStrip.h" |
tanabe2000 | 0:84c4f17abdc1 | 3 | |
tanabe2000 | 0:84c4f17abdc1 | 4 | #define WEIT 1000 |
tanabe2000 | 0:84c4f17abdc1 | 5 | #define LED_COUNT 60 |
tanabe2000 | 0:84c4f17abdc1 | 6 | #define RED 255 ,0 ,0 |
tanabe2000 | 0:84c4f17abdc1 | 7 | #define ORANGE 255 ,0 ,130 |
tanabe2000 | 0:84c4f17abdc1 | 8 | #define YELLOW 255 ,255,0 |
tanabe2000 | 0:84c4f17abdc1 | 9 | #define GREEN 0 ,255,0 |
tanabe2000 | 0:84c4f17abdc1 | 10 | #define LIGHT_BLUE 0 ,255,255 |
tanabe2000 | 0:84c4f17abdc1 | 11 | #define BLUE 0 ,0 ,255 |
tanabe2000 | 0:84c4f17abdc1 | 12 | #define PURPLE 0 ,255,130 |
tanabe2000 | 0:84c4f17abdc1 | 13 | #define PINK 255 ,0 ,255 |
tanabe2000 | 0:84c4f17abdc1 | 14 | |
tanabe2000 | 0:84c4f17abdc1 | 15 | |
tanabe2000 | 0:84c4f17abdc1 | 16 | Timer timer; |
tanabe2000 | 0:84c4f17abdc1 | 17 | PololuLedStrip ledStrip(PA_5); |
tanabe2000 | 0:84c4f17abdc1 | 18 | rgb_color colors[LED_COUNT]; |
tanabe2000 | 0:84c4f17abdc1 | 19 | |
tanabe2000 | 0:84c4f17abdc1 | 20 | void red (){ |
tanabe2000 | 0:84c4f17abdc1 | 21 | |
tanabe2000 | 0:84c4f17abdc1 | 22 | for(uint32_t i = 0; i < LED_COUNT; i++){ |
tanabe2000 | 0:84c4f17abdc1 | 23 | colors[i] = (rgb_color){255 ,0 ,0}; |
tanabe2000 | 0:84c4f17abdc1 | 24 | } |
tanabe2000 | 0:84c4f17abdc1 | 25 | ledStrip.write(colors, LED_COUNT); |
tanabe2000 | 0:84c4f17abdc1 | 26 | wait_ms(WEIT); |
tanabe2000 | 0:84c4f17abdc1 | 27 | } |
tanabe2000 | 0:84c4f17abdc1 | 28 | |
tanabe2000 | 0:84c4f17abdc1 | 29 | void orange (){ |
tanabe2000 | 0:84c4f17abdc1 | 30 | |
tanabe2000 | 0:84c4f17abdc1 | 31 | for(uint32_t i = 0; i < LED_COUNT; i++){ |
tanabe2000 | 0:84c4f17abdc1 | 32 | colors[i] = (rgb_color){ORANGE}; |
tanabe2000 | 0:84c4f17abdc1 | 33 | } |
tanabe2000 | 0:84c4f17abdc1 | 34 | ledStrip.write(colors, LED_COUNT); |
tanabe2000 | 0:84c4f17abdc1 | 35 | wait_ms(WEIT); |
tanabe2000 | 0:84c4f17abdc1 | 36 | |
tanabe2000 | 0:84c4f17abdc1 | 37 | } |
tanabe2000 | 0:84c4f17abdc1 | 38 | |
tanabe2000 | 0:84c4f17abdc1 | 39 | void yellow (){ |
tanabe2000 | 0:84c4f17abdc1 | 40 | |
tanabe2000 | 0:84c4f17abdc1 | 41 | for(uint32_t i = 0; i < LED_COUNT; i++){ |
tanabe2000 | 0:84c4f17abdc1 | 42 | colors[i] = (rgb_color){YELLOW}; |
tanabe2000 | 0:84c4f17abdc1 | 43 | } |
tanabe2000 | 0:84c4f17abdc1 | 44 | ledStrip.write(colors, LED_COUNT); |
tanabe2000 | 0:84c4f17abdc1 | 45 | wait_ms(WEIT); |
tanabe2000 | 0:84c4f17abdc1 | 46 | |
tanabe2000 | 0:84c4f17abdc1 | 47 | } |
tanabe2000 | 0:84c4f17abdc1 | 48 | |
tanabe2000 | 0:84c4f17abdc1 | 49 | void green (){ |
tanabe2000 | 0:84c4f17abdc1 | 50 | |
tanabe2000 | 0:84c4f17abdc1 | 51 | for(uint32_t i = 0; i < LED_COUNT; i++){ |
tanabe2000 | 0:84c4f17abdc1 | 52 | colors[i] = (rgb_color){GREEN}; |
tanabe2000 | 0:84c4f17abdc1 | 53 | } |
tanabe2000 | 0:84c4f17abdc1 | 54 | ledStrip.write(colors, LED_COUNT); |
tanabe2000 | 0:84c4f17abdc1 | 55 | wait_ms(WEIT); |
tanabe2000 | 0:84c4f17abdc1 | 56 | |
tanabe2000 | 0:84c4f17abdc1 | 57 | } |
tanabe2000 | 0:84c4f17abdc1 | 58 | |
tanabe2000 | 0:84c4f17abdc1 | 59 | void lgreen (){ |
tanabe2000 | 0:84c4f17abdc1 | 60 | |
tanabe2000 | 0:84c4f17abdc1 | 61 | for(uint32_t i = 0; i < LED_COUNT; i++){ |
tanabe2000 | 0:84c4f17abdc1 | 62 | colors[i] = (rgb_color){LIGHT_BLUE}; |
tanabe2000 | 0:84c4f17abdc1 | 63 | } |
tanabe2000 | 0:84c4f17abdc1 | 64 | ledStrip.write(colors, LED_COUNT); |
tanabe2000 | 0:84c4f17abdc1 | 65 | wait_ms(WEIT); |
tanabe2000 | 0:84c4f17abdc1 | 66 | |
tanabe2000 | 0:84c4f17abdc1 | 67 | } |
tanabe2000 | 0:84c4f17abdc1 | 68 | |
tanabe2000 | 0:84c4f17abdc1 | 69 | void blue (){ |
tanabe2000 | 0:84c4f17abdc1 | 70 | |
tanabe2000 | 0:84c4f17abdc1 | 71 | for(uint32_t i = 0; i < LED_COUNT; i++){ |
tanabe2000 | 0:84c4f17abdc1 | 72 | colors[i] = (rgb_color){BLUE}; |
tanabe2000 | 0:84c4f17abdc1 | 73 | } |
tanabe2000 | 0:84c4f17abdc1 | 74 | ledStrip.write(colors, LED_COUNT); |
tanabe2000 | 0:84c4f17abdc1 | 75 | wait_ms(WEIT); |
tanabe2000 | 0:84c4f17abdc1 | 76 | |
tanabe2000 | 0:84c4f17abdc1 | 77 | } |
tanabe2000 | 0:84c4f17abdc1 | 78 | |
tanabe2000 | 0:84c4f17abdc1 | 79 | void purple (){ |
tanabe2000 | 0:84c4f17abdc1 | 80 | |
tanabe2000 | 0:84c4f17abdc1 | 81 | for(uint32_t i = 0; i < LED_COUNT; i++){ |
tanabe2000 | 0:84c4f17abdc1 | 82 | colors[i] = (rgb_color){PURPLE}; |
tanabe2000 | 0:84c4f17abdc1 | 83 | } |
tanabe2000 | 0:84c4f17abdc1 | 84 | ledStrip.write(colors, LED_COUNT); |
tanabe2000 | 0:84c4f17abdc1 | 85 | wait_ms(WEIT); |
tanabe2000 | 0:84c4f17abdc1 | 86 | |
tanabe2000 | 0:84c4f17abdc1 | 87 | } |
tanabe2000 | 0:84c4f17abdc1 | 88 | |
tanabe2000 | 0:84c4f17abdc1 | 89 | void pink (){ |
tanabe2000 | 0:84c4f17abdc1 | 90 | |
tanabe2000 | 0:84c4f17abdc1 | 91 | for(uint32_t i = 0; i < LED_COUNT; i++){ |
tanabe2000 | 0:84c4f17abdc1 | 92 | colors[i] = (rgb_color){PINK}; |
tanabe2000 | 0:84c4f17abdc1 | 93 | } |
tanabe2000 | 0:84c4f17abdc1 | 94 | ledStrip.write(colors, LED_COUNT); |
tanabe2000 | 0:84c4f17abdc1 | 95 | wait_ms(WEIT); |
tanabe2000 | 0:84c4f17abdc1 | 96 | |
tanabe2000 | 0:84c4f17abdc1 | 97 | } |