Buonasera, sono nuovo di questo campo e avrei bisogno del vostro aiuto per correggere il mio codice, che allegherò di seguito.
Possiedo un Arduino Uno R3 ed una striscia di 50 cm con 30 led WS2813 e con essi vorrei creare un effetto dissolvenza con colori fissi, ma diversi per ogni led (per esempio led 0 colore bianco, led 1 colore rosso, led 2 colore blu... ecc.) ove l'intensità parta da 0(spenta) ed arrivi alla massima illuminazione in 3 minuti, pausa accesa di 5 minuti e dissolvenza in verso contrario.
Per ora sono riuscito a pilotare i led con i colori che voglio e creare un effetto "fade" di un unico colore senza però riuscire ad unirli.
Vi ringrazio anticipatamente per il vostro aiuto.
#include <FastLED.h>
#include <Adafruit_NeoPixel.h>
#define PIN 6
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino 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(30, PIN, NEO_GRB + NEO_KHZ800);
CRGB leds[NEO_GRB + NEO_KHZ800];
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel. Avoid connecting
// on a live circuit... if you must, connect GND first.
void setup() {
FastLED.addLeds<WS2813, PIN, GRB>(leds,NEO_GRB + NEO_KHZ800);
strip.begin();
strip.show(); // initialize all pixels to "off"
}
void loop() {
//sceglo i colori fissi da tenere ai led.
leds[0] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[1] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[2] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[3] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[4] = CRGB(255, 0, 0);
FastLED.show();
delay(500);
leds[5] = CRGB(0, 0, 255);
FastLED.show();
delay(500);
leds[6] = CRGB(255, 0, 0);
FastLED.show();
delay(500);
leds[7] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[8] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[9] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[10] = CRGB(255, 0, 0);
FastLED.show();
delay(500);
leds[11] = CRGB(0, 0, 255);
FastLED.show();
delay(500);
leds[12] = CRGB(255, 0, 0);
FastLED.show();
delay(500);
leds[13] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[14] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[15] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[16] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[17] = CRGB(255, 0, 0);
FastLED.show();
delay(500);
leds[18] = CRGB(0, 0, 255);
FastLED.show();
delay(500);
leds[19] = CRGB(255, 0, 0);
FastLED.show();
delay(500);
leds[20] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[21] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[22] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[23] = CRGB(255, 0, 0);
FastLED.show();
delay(500);
leds[24] = CRGB(0, 0, 255);
FastLED.show();
delay(500);
leds[25] = CRGB( 255, 0, 0);
FastLED.show();
delay(500);
leds[26] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[27] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[28] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
leds[29] = CRGB(170, 170, 170);
FastLED.show();
delay(500);
brighten();
darken();
}
// 0 to 255
void brighten() {
Serial.begin(9600);
uint16_t i, j;
for (j = 0; j < 255; j++) {
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, 0, 0, j);
}
strip.show();
delay(10);
}
delay(1500);
}
// 255 to 0
void darken() {
Serial.begin(9600);
uint16_t i, j;
for (j = 255; j > 0; j--) {
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, 0, 0, j);
}
strip.show();
delay(10);
Serial.println(j);
}
delay(1500);
}
prova_fede_e_fitos_1.ino (3.72 KB)