Skip to content

Instantly share code, notes, and snippets.

@jasonhejna
Last active August 31, 2020 19:41
Show Gist options
  • Save jasonhejna/8ddb065a19b77aaa8ce242ac353d6357 to your computer and use it in GitHub Desktop.
Save jasonhejna/8ddb065a19b77aaa8ce242ac353d6357 to your computer and use it in GitHub Desktop.
// Tyler's Lamp
#include <Adafruit_DotStar.h>
#include <SPI.h>
#define NUMPIXELS 62 // Number of LEDs in strip
// Here's how to control the LEDs from any two pins:
#define DATAPIN 6
#define CLOCKPIN 2
Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);
int Rainbow_Matrix[][3] = {
{0, 148, 211},
{0, 148, 211},
{0, 148, 211},
{0, 148, 211},
{0, 148, 211},
{0, 148, 211},
{0, 148, 211},
{0, 148, 211},
{0, 148, 211},
{0, 75, 130},
{0, 75, 130},
{0, 75, 130},
{0, 75, 130},
{0, 75, 130},
{0, 75, 130},
{0, 75, 130},
{0, 75, 130},
{0, 75, 130},
{0, 0, 255},
{0, 0, 255},
{0, 0, 255},
{0, 0, 255},
{0, 0, 255},
{0, 0, 255},
{0, 0, 255},
{0, 0, 255},
{0, 0, 255},
{255, 0, 0},
{255, 0, 0},
{255, 0, 0},
{255, 0, 0},
{255, 0, 0},
{255, 0, 0},
{255, 0, 0},
{255, 0, 0},
{255, 0, 0},
{255, 255, 0},
{255, 255, 0},
{255, 255, 0},
{255, 255, 0},
{255, 255, 0},
{255, 255, 0},
{255, 255, 0},
{255, 255, 0},
{255, 255, 0},
{127, 255, 0},
{127, 255, 0},
{127, 255, 0},
{127, 255, 0},
{127, 255, 0},
{127, 255, 0},
{127, 255, 0},
{127, 255, 0},
{127, 255, 0},
{0, 255, 0},
{0, 255, 0},
{0, 255, 0},
{0, 255, 0},
{0, 255, 0},
{0, 255, 0},
{0, 255, 0},
{0, 255, 0},
{0, 255, 0},
};
int start = 0;
int count_remainder = 0;
int i;
int motion_pin = 4;
int motion = false;
void setup() {
Serial.begin(9600);
strip.begin(); // Initialize pins for output
strip.setBrightness(128);
strip.show(); // Turn all LEDs off ASAP
pinMode(motion_pin, INPUT);
}
void loop() {
motion = digitalRead(motion_pin);
if (motion == true) {// G R B
for (i=start; i<NUMPIXELS; i++) {
strip.setPixelColor(count_remainder, Rainbow_Matrix[i][0], Rainbow_Matrix[i][1], Rainbow_Matrix[i][2]);
count_remainder++;
}
for (i=0; i<start; i++) {
strip.setPixelColor(count_remainder, Rainbow_Matrix[i][0], Rainbow_Matrix[i][1], Rainbow_Matrix[i][2]);
count_remainder++;
}
strip.show();
start++;
if (start > 61) start = 0;
count_remainder = 0;
//delay(150); // how fast the lights move
}
else{
for (i=0; i<NUMPIXELS; i++) {
strip.setPixelColor(i, 0, 0, 0);
}
strip.show();
}
Serial.write("A Tyler Production\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment