Last active
August 12, 2020 20:16
-
-
Save jasonhejna/a5660579491c037f4f4416193242603f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LAMP 198 | |
#include <Adafruit_DotStar.h> | |
#include <SPI.h> | |
#define NUMPIXELS 60 // Number of LEDs in strip | |
// Here's how to control the LEDs from any two pins: | |
#define DATAPIN 2 | |
#define CLOCKPIN 6 | |
Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG); | |
int height_1; | |
int height_2; | |
int c1_rand_1; | |
int c1_rand_2; | |
int c1_rand_3; | |
int c2_rand_1; | |
int c2_rand_2; | |
int c2_rand_3; | |
int c3_rand_1; | |
int c3_rand_2; | |
int c3_rand_3; | |
int i; | |
int j; | |
int k; | |
void setup() { | |
Serial.begin(9600); | |
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000L) | |
clock_prescale_set(clock_div_1); // Enable 16 MHz on Trinket | |
#endif | |
randomSeed(analogRead(0)); | |
height_1 = random(4,40); | |
height_2 = random(height_1+5,55); | |
//Serial.println(height_1); | |
//Serial.println(height_2); | |
while(1){ | |
c1_rand_1 = random(0,255); | |
c1_rand_2 = random(0,255); | |
c1_rand_3 = random(0,255); | |
if (c1_rand_1 < 5 || c1_rand_2 < 5 || c1_rand_3 < 5) { | |
break; | |
} | |
} | |
while (1){ | |
c2_rand_1 = random(0,255); | |
c2_rand_2 = random(0,255); | |
c2_rand_3 = random(0,255); | |
if (c2_rand_1 < 5 || c2_rand_2 < 5 || c2_rand_3 < 5) { | |
break; | |
} | |
} | |
while (1){ | |
c3_rand_1 = random(0,255); | |
c3_rand_2 = random(0,255); | |
c3_rand_3 = random(0,255); | |
if (c3_rand_1 < 5 || c3_rand_2 < 5 || c3_rand_3 < 5) { | |
break; | |
} | |
} | |
strip.begin(); // Initialize pins for output | |
strip.setBrightness(255); | |
strip.show(); // Turn all LEDs off ASAP | |
for (i=0; i<NUMPIXELS; i++) { | |
strip.setPixelColor(i,255, 0, 0); | |
strip.show(); | |
delay(30); | |
} | |
for (i=NUMPIXELS; i>0; i--) { | |
strip.setPixelColor(i, 0, 255, 0); | |
strip.show(); | |
delay(20); | |
} | |
} | |
void loop() { | |
for (i=0; i<height_1; i++) { | |
strip.setPixelColor(i, c1_rand_1, c1_rand_2, c1_rand_3); | |
} | |
for (j=height_1; j<height_2; j++) { | |
strip.setPixelColor(j, c2_rand_1, c2_rand_2, c2_rand_3); | |
} | |
for (k=height_2; k<NUMPIXELS; k++) { | |
strip.setPixelColor(k, c3_rand_1, c3_rand_2, c3_rand_3); | |
} | |
strip.show(); | |
Serial.write("https://gist.github.com/jasonhejna/a5660579491c037f4f4416193242603f\n"); | |
delay(20000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment