Hi Hans,
First the title "Halloween Eyes" does not really fit my project. It would rather be the "Eye of the Cyclops"
(I use for now only one LED - Not one LED Strip).
But in the end and to make it more romantic it is about "Soft luminous variations" (Brooch, headband, neckband, etc.) for pretty girls
(See image of a brooch/pin - next Post - Due to problem of Forum).
Equipment used: ATtiny85 + 1x LED RGB "WS2812B".
The base comes from: "Blinking Halloween Eyes".
This is the random side that interested me - but I guess this script can be much simplified.
Currently I come back with another color with function: [setAll(0x94, 0x00, 0xD3);].
I would just edit this script to: (write another)
a) Use 1 LED (eg 2-3 LEDs in random sequence);
b) Use 2-3 colors (possibly 3rd colors as black) - See interaction with: [setAll(0,0,0);];
c) Get a Fade-In & Fade-Out effect - Between each color;
d) All with random functions !
My current script: (based on "NeoPixel" Adafruit)
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 4
#define NUM_LEDS 1
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.setBrightness(64); // Decrease the brightness of the LEDs.
strip.show(); // Initialize all pixels to 'off'
}
// REPLACE FROM HERE
void loop() {
// Fixed:
// HalloweenEyes(0xff, 0x00, 0x00, 1,4, true, 10, 80, 3000);
// or Random:
HalloweenEyes(0x94, 0x00, 0xD3, // DarkViolet.
1, 1,
true, random(20,120), random(150,300),
random(5000, 15000));
}
void HalloweenEyes(byte red, byte green, byte blue,
int EyeWidth, int EyeSpace,
boolean Fade, int Steps, int FadeDelay,
int EndPause){
randomSeed(analogRead(0));
int i;
int StartPoint = random( 0, NUM_LEDS - (2*EyeWidth) - EyeSpace );
int Start2ndEye = StartPoint + EyeWidth + EyeSpace;
for(i = 0; i < EyeWidth; i++) {
setPixel(StartPoint + i, red, green, blue);
setPixel(Start2ndEye + i, red, green, blue);
}
showStrip();
if(Fade==true) {
float r, g, b;
for(int j = Steps; j >= 0; j--) {
r = j*(red/Steps);
g = j*(green/Steps);
b = j*(blue/Steps);
for(i = 0; i < EyeWidth; i++) {
setPixel(StartPoint + i, r, g, b);
setPixel(Start2ndEye + i, r, g, b);
}
showStrip();
delay(FadeDelay);
}
}
setAll(0x94, 0x00, 0xD3); // Set all DarkViolet.
delay(EndPause);
}
// REPLACE TO HERE
void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}
I hope you can help me.
I am waiting for your comments. Thank you !
Guy-Laurent
PS: And do not forget to turn On the coffee maker