Hi,
i'm currently trying to setup an art project i'll try to resume here :
First it's a tree, lights are hanging from the branches and the tree has to then light from the tom to the bottom. Once the song is over, it goes out bottom to top and then the first lights goes out all at once.
So :
-Put a magnetic trigger on magnetic switch
-music start
- Some very specific lights go on (only the lights coming on the outside)
-The led at the top of the tree (number 28 ) lights
-All the others leds lights in a chain
BUT
giving that the top led is n°28 (non negociable), i have to light leds from 28 -50 and 27-0
and i'm kinda struggling on this one, cause with my code, there not lighting at the same time...
Could you please help me figure out ?
Please remember it's my very first project and i'm not use to code (nor english is my native language but i guess you figured out)
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
#include <FastLED.h>
#define LED_PIN 5
#define COLOR_ORDER GRB
#define CHIPSET WS2811
#define NUM_LEDS 50
#define BRIGHTNESS 100
#define FRAMES_PER_SECOND 60
CRGB leds[NUM_LEDS];
// Use pins 2 and 3 to communicate with DFPlayer Mini
static const uint8_t PIN_MP3_TX = 4; // Connects to module's RX
static const uint8_t PIN_MP3_RX = 3; // Connects to module's TX
SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);
// Create the Player object
DFRobotDFPlayerMini player;
//delay pour les leds du tronc
void setup () {
//leds setup
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
//SOUNDS SETUP
// Init USB serial port for debugging
Serial.begin(9600);
// Init serial port for DFPlayer Mini
softwareSerial.begin(9600);
// Start communication with DFPlayer Mini
if (player.begin(softwareSerial)) {
Serial.println("OK");
// Set volume to maximum (0 to 30).
player.volume(0); //20
// Play the first MP3 file on the SD card
player.play(1);
} else {
Serial.println("Connecting to DFPlayer Mini failed!");
}
}
void loop() {
{ //musique
}
//attente
delay(3000);
//allumage leds
bottles();
delay(1000);
LedFin();
LedDebut();
delay(1000);
couleur_fin();
}
void bottles() {
{
leds[7] = CRGB(216, 100, 0);
delay(500);
FastLED.show();
leds[9] = CRGB(216, 100, 0);
delay(500);
FastLED.show();
leds[13] = CRGB(216, 100, 0);
delay(500);
FastLED.show();
leds[15] = CRGB(216, 100, 0);
delay(500);
FastLED.show();
leds[19] = CRGB(216, 100, 0);
delay(500);
FastLED.show();
leds[21] = CRGB(216, 100, 0);
delay(500);
FastLED.show();
leds[24] = CRGB(216, 100, 0);
delay(500);
FastLED.show();
}
}
void LedFin() {
for (int i = 28; i < NUM_LEDS; i++)
{
leds[i] = CRGB(216, 100, 0);
delay(100);
FastLED.show();
}
}
void LedDebut() {
for (int i = 28; i > 0; i--)
{
leds[i] = CRGB(216, 100, 0);
delay(100);
FastLED.show();
}
}
void couleur_fin() {
for (int i = 50; i < NUM_LEDS; i--) {
leds[i] = CRGB::Black;
delay(100);
FastLED.show();
}
}