Make work with great variety of things
This commit is contained in:
parent
3fbafaf0ec
commit
5b3f64ae79
20
README.md
20
README.md
|
@ -15,7 +15,7 @@ I found a good 10A power supply for about $12 on Amazon.
|
||||||
You can probably salvage one from some old thing.
|
You can probably salvage one from some old thing.
|
||||||
|
|
||||||
If you have under 80 lights, you can use an Adafruit Trinket.
|
If you have under 80 lights, you can use an Adafruit Trinket.
|
||||||
I used an Adafruit Pro Trinket for mine, which has 150+ lights.
|
I used an Adafruit Pro Trinket for my 182-light display.
|
||||||
(It's an issue of RAM).
|
(It's an issue of RAM).
|
||||||
|
|
||||||
Of course, a standard Arduino will work just fine too!
|
Of course, a standard Arduino will work just fine too!
|
||||||
|
@ -23,9 +23,9 @@ Of course, a standard Arduino will work just fine too!
|
||||||
This was coded to color-correct a specific type of GRB LEDs on wires I got from Amazon.
|
This was coded to color-correct a specific type of GRB LEDs on wires I got from Amazon.
|
||||||
It's coded to match the lights we already have, which are biased toward yellow and amber.
|
It's coded to match the lights we already have, which are biased toward yellow and amber.
|
||||||
|
|
||||||
You may have gotten lights wired RGB, in which case this is going to look very green.
|
You may have gotten lights wired GRB, in which case this is going to look very green.
|
||||||
It should be just a matter of switching the first two bytes in each color definition
|
It should be just a matter of switching the first two bytes in each color definition
|
||||||
to go from GRB to RGB.
|
to go from RGB to GRB.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ Setup
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Plug your lights into pin 6 (or whatever you set `PIN` to in the code).
|
Plug your lights into pin 6 (or whatever you set `PIN` to in the code).
|
||||||
Set `NUM_LEDS` in the code to how many are in your strip.
|
|
||||||
|
|
||||||
Give the strip power and ground.
|
Give the strip power and ground.
|
||||||
If you have more than about 80 LEDs, you might need to provide an external
|
If you have more than about 80 LEDs, you might need to provide an external
|
||||||
|
@ -42,7 +41,12 @@ You can plug the LED strip into the +5v on the power supply;
|
||||||
You can power your microcontroller from the beefier power supply, too,
|
You can power your microcontroller from the beefier power supply, too,
|
||||||
so you don't have to run USB just to power the microcontroller.
|
so you don't have to run USB just to power the microcontroller.
|
||||||
|
|
||||||
The code as written wants pin 4 to be connected to ground.
|
|
||||||
When you disconnect it,
|
Usage
|
||||||
the whole strand goes white.
|
-------
|
||||||
My family has a tradition of the tree going from colors to white on the morning of the 25th.
|
|
||||||
|
Just provide power.
|
||||||
|
|
||||||
|
If you connect `WHITE_PIN` to ground,
|
||||||
|
everything goes white,
|
||||||
|
which is a tradition in my family on xmas morning.
|
||||||
|
|
|
@ -3,21 +3,42 @@
|
||||||
#include <avr/power.h>
|
#include <avr/power.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Which pin your LED strip is connected to
|
||||||
|
#ifdef Attiny85
|
||||||
|
# define PIN 3
|
||||||
|
#else
|
||||||
# define PIN 6
|
# define PIN 6
|
||||||
#define NUM_LEDS 150
|
#endif
|
||||||
|
|
||||||
|
// Which pin to pull to go full white. Comment to disable this feature.
|
||||||
#define WHITE_PIN 4
|
#define WHITE_PIN 4
|
||||||
|
|
||||||
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB | NEO_KHZ800);
|
// Order of the lights you got
|
||||||
|
|
||||||
|
// How many LEDs you have. It's okay if this is too big.
|
||||||
|
#ifdef Attiny85
|
||||||
|
# define NUM_LEDS 80
|
||||||
|
#else
|
||||||
|
# define NUM_LEDS 200
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// What percentage chance a chosen light has of being on
|
||||||
|
#define ACTIVITY 50
|
||||||
|
|
||||||
|
// Debug LED
|
||||||
|
#define LED_PIN 1
|
||||||
|
|
||||||
|
|
||||||
|
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_RGB | NEO_KHZ800);
|
||||||
|
|
||||||
const uint32_t colors[] = {
|
const uint32_t colors[] = {
|
||||||
0x440000, // Green
|
0x004400, // Green
|
||||||
0x44dd00, // Yellow
|
0xdd4400, // Yellow
|
||||||
0x44dd00, // Yellow
|
0xdd4400, // Yellow
|
||||||
0x22dd00, // Amber
|
0xdd2200, // Amber
|
||||||
0x22dd00, // Amber
|
0xdd2200, // Amber
|
||||||
0x00ff00, // Red
|
0x0000ff, // Red
|
||||||
0x008844, // Purple
|
0x880044, // Purple
|
||||||
0x000088, // Blue
|
0x000088, // Blue
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -26,13 +47,19 @@ const int ncolors = sizeof(colors) / sizeof(*colors);
|
||||||
void setup() {
|
void setup() {
|
||||||
strip.begin();
|
strip.begin();
|
||||||
strip.show();
|
strip.show();
|
||||||
|
#ifdef WHITE_PIN
|
||||||
pinMode(WHITE_PIN, INPUT_PULLUP);
|
pinMode(WHITE_PIN, INPUT_PULLUP);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LED_PIN
|
||||||
|
pinMode(LED_PIN, OUTPUT);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop_color() {
|
void loop_color() {
|
||||||
for (int i = 0; i < NUM_LEDS/12; i += 1) {
|
for (int i = 0; i < NUM_LEDS/12; i += 1) {
|
||||||
int pos = random(NUM_LEDS);
|
int pos = random(NUM_LEDS);
|
||||||
if (random(100) < 20) {
|
if (random(100) < ACTIVITY) {
|
||||||
int color = random(ncolors);
|
int color = random(ncolors);
|
||||||
strip.setPixelColor(pos, colors[color]);
|
strip.setPixelColor(pos, colors[color]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,9 +84,19 @@ void loop_white() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
if (digitalRead(WHITE_PIN)) {
|
#ifdef WHITE_PIN
|
||||||
|
if (! digitalRead(WHITE_PIN)) {
|
||||||
loop_white();
|
loop_white();
|
||||||
} else {
|
} else {
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
#endif
|
||||||
loop_color();
|
loop_color();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LED_PIN
|
||||||
|
static bool led = true;
|
||||||
|
digitalWrite(LED_PIN, led);
|
||||||
|
led = !led;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue