Skip to content

Instantly share code, notes, and snippets.

@LimeBlast
Created June 9, 2016 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LimeBlast/de98f0f5c18ed6b87361e30060a2a596 to your computer and use it in GitHub Desktop.
Save LimeBlast/de98f0f5c18ed6b87361e30060a2a596 to your computer and use it in GitHub Desktop.
/* Include the HCWS2812 library */
#include "HCWS2812.h"
/* Create an instance of the library */
HCWS2812 HCWS2812;
void setup()
{
/* Set the R,G,B background colours to zero */
HCWS2812.SetBG(55, 55, 55);
/* Clear the output buffer */
HCWS2812.ClearBuffer();
}
/* Main program */
void loop()
{
int i = random(NUMBEROFLEDS);
int j;
HCWS2812.ClearBuffer();
/* quick fade in */
for(j = 0; j < 40; j++)
{
RGBBuffer[RED][i] = j * 5 + 55;
RGBBuffer[GREEN][i] = j * 5 + 55;
RGBBuffer[BLUE][i] = j * 5 + 55;
HCWS2812.Refresh();
delay(10);
}
/* slow fade out */
for(j = 40; j; j--)
{
HCWS2812.ClearBuffer();
RGBBuffer[RED][i] = j * 5 + 55;
RGBBuffer[GREEN][i] = j * 5 + 55;
RGBBuffer[BLUE][i] = j * 5 + 55;
HCWS2812.Refresh();
delay(80);
}
HCWS2812.ClearBuffer();
HCWS2812.Refresh();
delay(200);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment