This is an example program for the PololuLedStrip library. It generates a simple moving gradient pattern.

Dependencies:   PololuLedStrip mbed LedStripGradient

Dependents:   LedStripGradient led_phare_crf

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "PololuLedStrip.h"
00003 
00004 PololuLedStrip ledStrip(D8);
00005 
00006 #define LED_COUNT 60
00007 rgb_color colors[LED_COUNT];
00008 
00009 Timer timer;
00010 
00011 int main()
00012 {
00013     timer.start();
00014 
00015     while(1)
00016     {
00017         // Update the colors array.
00018         uint8_t time = timer.read_ms() >> 2;
00019         for(uint32_t i = 0; i < LED_COUNT; i++)
00020         {
00021             uint8_t x = time - 8*i;
00022             colors[i] = (rgb_color){ x, 255 - x, x };
00023         }
00024     
00025         // Send the colors to the LED strip.
00026         ledStrip.write(colors, LED_COUNT);
00027         wait_ms(10);        
00028     }
00029 }