Forked PololuLedStrip and modified it to work with the KL25Z. Renamed it to Adafruit_NeoPixel.
Dependents: idd_hw3 idd_fa15_hw3_lauren_bill_tomas idd_fa15_hw3_lauren_bill_tomas Raiden ... more
Fork of PololuLedStrip by
Examples/LedStripGradient.cpp@23:a3c2ccd5870c, 2015-09-16 (annotated)
- Committer:
- tomasero
- Date:
- Wed Sep 16 22:37:58 2015 +0000
- Revision:
- 23:a3c2ccd5870c
- Child:
- 24:21d6d7016965
Added example from PololuLedStrip. Modified NeoPixel DataIn pin to PTC8 (pin 6).
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tomasero | 23:a3c2ccd5870c | 1 | #include "mbed.h" |
tomasero | 23:a3c2ccd5870c | 2 | #include "PololuLedStrip.h" |
tomasero | 23:a3c2ccd5870c | 3 | |
tomasero | 23:a3c2ccd5870c | 4 | PololuLedStrip ledStrip(PTC8); |
tomasero | 23:a3c2ccd5870c | 5 | |
tomasero | 23:a3c2ccd5870c | 6 | #define LED_COUNT 60 |
tomasero | 23:a3c2ccd5870c | 7 | rgb_color colors[LED_COUNT]; |
tomasero | 23:a3c2ccd5870c | 8 | |
tomasero | 23:a3c2ccd5870c | 9 | Timer timer; |
tomasero | 23:a3c2ccd5870c | 10 | |
tomasero | 23:a3c2ccd5870c | 11 | int main() |
tomasero | 23:a3c2ccd5870c | 12 | { |
tomasero | 23:a3c2ccd5870c | 13 | timer.start(); |
tomasero | 23:a3c2ccd5870c | 14 | |
tomasero | 23:a3c2ccd5870c | 15 | while(1) |
tomasero | 23:a3c2ccd5870c | 16 | { |
tomasero | 23:a3c2ccd5870c | 17 | // Update the colors array. |
tomasero | 23:a3c2ccd5870c | 18 | uint8_t time = timer.read_ms() >> 2; |
tomasero | 23:a3c2ccd5870c | 19 | for(uint32_t i = 0; i < LED_COUNT; i++) |
tomasero | 23:a3c2ccd5870c | 20 | { |
tomasero | 23:a3c2ccd5870c | 21 | uint8_t x = time - 8*i; |
tomasero | 23:a3c2ccd5870c | 22 | colors[i] = (rgb_color){ x, 255 - x, x }; |
tomasero | 23:a3c2ccd5870c | 23 | } |
tomasero | 23:a3c2ccd5870c | 24 | |
tomasero | 23:a3c2ccd5870c | 25 | // Send the colors to the LED strip. |
tomasero | 23:a3c2ccd5870c | 26 | ledStrip.write(colors, LED_COUNT); |
tomasero | 23:a3c2ccd5870c | 27 | wait_ms(10); |
tomasero | 23:a3c2ccd5870c | 28 | } |
tomasero | 23:a3c2ccd5870c | 29 | } |