Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Adafruit_WS2801 mbed
main.cpp@0:63c1f03ccb9c, 2015-01-16 (annotated)
- Committer:
- AlanRager
- Date:
- Fri Jan 16 05:36:27 2015 +0000
- Revision:
- 0:63c1f03ccb9c
- Child:
- 1:54cf3c557fdf
initial commit - got lights binking, and I think I messed up the commit message for the adafruit library updates
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| AlanRager | 0:63c1f03ccb9c | 1 | #include "mbed.h" |
| AlanRager | 0:63c1f03ccb9c | 2 | #include "Adafruit_WS2801.h" |
| AlanRager | 0:63c1f03ccb9c | 3 | |
| AlanRager | 0:63c1f03ccb9c | 4 | #define LED_NUM 32 |
| AlanRager | 0:63c1f03ccb9c | 5 | #define RED 1 |
| AlanRager | 0:63c1f03ccb9c | 6 | #define GREEN 2 |
| AlanRager | 0:63c1f03ccb9c | 7 | #define BLUE 4 |
| AlanRager | 0:63c1f03ccb9c | 8 | |
| AlanRager | 0:63c1f03ccb9c | 9 | //Init strip of 32 |
| AlanRager | 0:63c1f03ccb9c | 10 | Adafruit_WS2801 leds( LED_NUM, SPI_MOSI, SPI_SCK, WS2801_RGB ); |
| AlanRager | 0:63c1f03ccb9c | 11 | |
| AlanRager | 0:63c1f03ccb9c | 12 | int main () { |
| AlanRager | 0:63c1f03ccb9c | 13 | int i, color; |
| AlanRager | 0:63c1f03ccb9c | 14 | |
| AlanRager | 0:63c1f03ccb9c | 15 | color = 1; |
| AlanRager | 0:63c1f03ccb9c | 16 | |
| AlanRager | 0:63c1f03ccb9c | 17 | while (1) { |
| AlanRager | 0:63c1f03ccb9c | 18 | for (i = 0; i < LED_NUM; i++){ |
| AlanRager | 0:63c1f03ccb9c | 19 | leds.setPixelColor( |
| AlanRager | 0:63c1f03ccb9c | 20 | i, |
| AlanRager | 0:63c1f03ccb9c | 21 | ( color & RED ), |
| AlanRager | 0:63c1f03ccb9c | 22 | ( color & BLUE ), |
| AlanRager | 0:63c1f03ccb9c | 23 | ( color & GREEN ) |
| AlanRager | 0:63c1f03ccb9c | 24 | ); |
| AlanRager | 0:63c1f03ccb9c | 25 | } |
| AlanRager | 0:63c1f03ccb9c | 26 | leds.show(); |
| AlanRager | 0:63c1f03ccb9c | 27 | wait_ms(1); |
| AlanRager | 0:63c1f03ccb9c | 28 | |
| AlanRager | 0:63c1f03ccb9c | 29 | color = color * 2; |
| AlanRager | 0:63c1f03ccb9c | 30 | |
| AlanRager | 0:63c1f03ccb9c | 31 | if ( color > GREEN ) { |
| AlanRager | 0:63c1f03ccb9c | 32 | color = RED ; |
| AlanRager | 0:63c1f03ccb9c | 33 | } |
| AlanRager | 0:63c1f03ccb9c | 34 | } |
| AlanRager | 0:63c1f03ccb9c | 35 | } |