Skip to content

Instantly share code, notes, and snippets.

@yyolk
Forked from greymechanic/ws2801BASE
Last active December 20, 2015 07:29
Show Gist options
  • Save yyolk/6093896 to your computer and use it in GitHub Desktop.
Save yyolk/6093896 to your computer and use it in GitHub Desktop.
#include "SPI.h"
#include "Adafruit_WS2801.h"
Adafruit_WS2801 strip = Adafruit_WS2801(32);
void setup() {
Serial.begin(115200);
strip.begin();
strip.show();
}
void loop() {
int slow = 200;
colorWipe(Color(255, 255, 255), slow);
}
void colorWipe(uint32_t c, uint8_t wait) {
int i;
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
// Create a 24 bit color value from R,G,B
uint32_t Color(byte r, byte g, byte b)
{
uint32_t c;
c = r;
c <<= 8;
c |= g;
c <<= 8;
c |= b;
return c;
}
//Input a value 0 to 255 to get a color value.
//The colours are a transition r - g -b - back to r
uint32_t Wheel(byte WheelPos)
{
if (WheelPos < 85) {
return Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if (WheelPos < 170) {
WheelPos -= 85;
return Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment