Created
April 7, 2020 22:21
-
-
Save jasonhejna/25d265a072640319611ae56420fda2a6 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
// Simple strand test for Adafruit Dot Star RGB LED strip. | |
// This is a basic diagnostic tool, NOT a graphics demo...helps confirm | |
// correct wiring and tests each pixel's ability to display red, green | |
// and blue and to forward data down the line. By limiting the number | |
// and color of LEDs, it's reasonably safe to power a couple meters off | |
// the Arduino's 5V pin. DON'T try that with other code! | |
#include <Adafruit_DotStar.h> | |
// Because conditional #includes don't work w/Arduino sketches... | |
#include <SPI.h> // COMMENT OUT THIS LINE FOR GEMMA OR TRINKET | |
//#include <avr/power.h> // ENABLE THIS LINE FOR GEMMA OR TRINKET | |
#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); | |
// The last parameter is optional -- this is the color data order of the | |
// DotStar strip, which has changed over time in different production runs. | |
// Your code just uses R,G,B colors, the library then reassigns as needed. | |
// Default is DOTSTAR_BRG, so change this if you have an earlier strip. | |
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() { | |
#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); | |
c1_rand_1 = random(0,255); | |
c1_rand_2 = random(0,255); | |
c1_rand_3 = random(0,255); | |
c2_rand_1 = random(0,255); | |
c2_rand_2 = random(0,255); | |
c2_rand_3 = random(0,255); | |
c3_rand_1 = random(0,255); | |
c3_rand_2 = random(0,255); | |
c3_rand_3 = random(0,255); | |
strip.begin(); // Initialize pins for output | |
strip.setBrightness(128); | |
strip.show(); // Turn all LEDs off ASAP | |
} | |
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(); | |
delay(20000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment