Ciao a tutti, rieccomi qua dopo vari progetti e più esperienza, ma non riesco a fare questo:
ho n strisce led, su una faccio andare su e giù dei colori, la seconda blink rosso etc. In pratica ogni striscia può avere un suo effetto. Il problema è che nel loop {} passo da un effetto all'altro , in pratica finisce il primo e poi va al secondo e di conseguenza il primo si ferma.
Qeesta è la parte del codice loop
//striscia 0
for(int a=0;a<100;a++){
animationA();
animationB();
uint8_t ratio = beatsin8(2); // Alternate between 0 and 255 every minute
// This inner loo= p will go over each led in the current strip, one at a time
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
leds[0][i] = blend( leds2[i], leds3[i], ratio );
}
FastLED.show();
}
//striscia 1
for(int a=0;a<100;a++){
animationA();
animationB();
uint8_t ratio = beatsin8(2); // Alternate between 0 and 255 every minute
// This inner loop will go over each led in the current strip, one at a time
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
leds[1][i] = blend( leds2[i], leds3[i], ratio );
}
FastLED.show();
}
//striscia 2
for(int a=0;a<100;a++){
animationA();
animationB();
uint8_t ratio = beatsin8(2); // Alternate between 0 and 255 every minute
// This inner loop will go over each led in the current strip, one at a time
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
leds[2][i] = blend( leds2[i], leds3[i], ratio );
}
FastLED.show();
}
// seguirebbero le altre striscie
//altri effetti
coloriinlinea();
}
//END LOOP
Praticamente striscia0 va a completamento(for a),poi parte stricia1 etcc. Io vorrei che stricia0 continuasse a fare l'effetto poi(dopo il ciclo for a) partisse striscia1 e che striscia0 continuasse, poi parte striscia2 e striscia 0 e 1 continuassero e così via.
Invece parte striscia1 e striscia0 si ferma (ed è corretto perchè il loop lavora così), ma non so come fare quanto vorrei! ![]()
Questo tutto il codice
#include "FastLED.h"
#define BRIGHTNESS 64
#define NUM_STRIPS 7 //SETTE NON OTTO
#define NUM_LEDS_PER_STRIP 20
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
//CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];
CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];
#define UPDATES_PER_SECOND 100
//per animationA
CRGB leds2[NUM_LEDS_PER_STRIP];
CRGB leds3[NUM_LEDS_PER_STRIP];
int s = 0;
////////////////////////////
void setup() {
delay( 1000 ); // power-up safety delay
Serial.begin(9600);
FastLED.addLeds<LED_TYPE, 4, COLOR_ORDER>(leds[0], NUM_LEDS_PER_STRIP).setCorrection( TypicalLEDStrip );
FastLED.addLeds<LED_TYPE, 5, COLOR_ORDER>(leds[1], NUM_LEDS_PER_STRIP).setCorrection( TypicalLEDStrip );
FastLED.addLeds<LED_TYPE, 6, COLOR_ORDER>(leds[2], NUM_LEDS_PER_STRIP).setCorrection( TypicalLEDStrip );
FastLED.addLeds<LED_TYPE, 7, COLOR_ORDER>(leds[3], NUM_LEDS_PER_STRIP).setCorrection( TypicalLEDStrip );
FastLED.addLeds<LED_TYPE, 8, COLOR_ORDER>(leds[4], NUM_LEDS_PER_STRIP).setCorrection( TypicalLEDStrip );
FastLED.addLeds<LED_TYPE, 9, COLOR_ORDER>(leds[5], NUM_LEDS_PER_STRIP).setCorrection( TypicalLEDStrip );
FastLED.addLeds<LED_TYPE, 10, COLOR_ORDER>(leds[6], NUM_LEDS_PER_STRIP).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
} //Setup()
void loop() {
//striscia 0
for(int a=0;a<100;a++){
animationA();
animationB();
uint8_t ratio = beatsin8(2); // Alternate between 0 and 255 every minute
// This inner loo= p will go over each led in the current strip, one at a time
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
leds[0][i] = blend( leds2[i], leds3[i], ratio );
}
FastLED.show();
}
//striscia 1
for(int a=0;a<100;a++){
animationA();
animationB();
uint8_t ratio = beatsin8(2); // Alternate between 0 and 255 every minute
// This inner loop will go over each led in the current strip, one at a time
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
leds[1][i] = blend( leds2[i], leds3[i], ratio );
}
FastLED.show();
}
//striscia 2
for(int a=0;a<100;a++){
animationA();
animationB();
uint8_t ratio = beatsin8(2); // Alternate between 0 and 255 every minute
// This inner loop will go over each led in the current strip, one at a time
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
leds[2][i] = blend( leds2[i], leds3[i], ratio );
}
FastLED.show();
}
// seguirebbero le altre striscie
//altri effetti
coloriinlinea();
}
//END LOOP
void animationA() { // running red stripe.
for (int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
uint8_t red = (millis() / 10) + (i * 12); // speed, length
if (red > 128) red = 0;
leds2[i] = CRGB(red, 0, 0);
}
} // animationA()
void animationB() { // running green stripe in opposite direction.
for (int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
uint8_t green = (millis() / 5) - (i * 12); // speed, length
if (green > 128) green = 0;
leds3[i] = CRGB(0, green, 0);
}
} // animationB()
void singolestrisce()
{
// This outer loop will go over each strip, one at a time
for(int x = 0; x < NUM_STRIPS; x++) {
// This inner loop will go over each led in the current strip, one at a time
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
leds[x][i] = CRGB::Green;
leds[x][i+1] = CRGB::White;
leds[x][i+2] = CRGB::Red;
FastLED.show();
leds[x][i] = CRGB::Black;
delay(10);
}
}
}//singolestrisce
void coloriinlinea(){
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
// set our current dot to red, green, and blue
leds[0][i] = CRGB::Gold;
leds[1][i] = CRGB::Coral;
leds[2][i] = CRGB::Aqua;
leds[3][i] = CRGB::Yellow;
leds[4][i] = CRGB::HotPink;
leds[5][i] = CRGB::Magenta;
leds[6][i] = CRGB::LightBlue;
FastLED.show();
// clear our current dot before we move on
leds[0][i] = CRGB::Black;
leds[1][i] = CRGB::Black;
leds[2][i] = CRGB::Black;
leds[3][i] = CRGB::Black;
leds[4][i] = CRGB::Black;
leds[5][i] = CRGB::Black;
leds[6][i] = CRGB::Black;
delay(100);
}
for(int i = NUM_LEDS_PER_STRIP-1; i >= 0; i--) {
// set our current dot to red, green, and blue
leds[0][i] = CRGB::Red;
leds[1][i] = CRGB::Green;
leds[2][i] = CRGB::Blue;
leds[3][i] = CRGB::Red;
leds[4][i] = CRGB::Green;
leds[5][i] = CRGB::Blue;
leds[6][i] = CRGB::Red;
FastLED.show();
// clear our current dot before we move on
leds[0][i] = CRGB::Black;
leds[1][i] = CRGB::Black;
leds[2][i] = CRGB::Black;
leds[3][i] = CRGB::Black;
leds[4][i] = CRGB::Black;
leds[5][i] = CRGB::Black;
leds[6][i] = CRGB::Black;
delay(100);
}
}//coloriinlenea
Grazie a chi mi aiuta