Hi, i'm new to arduino and led strips and have a school project involving them. I'm running into the problem that when I power the led strip and the arduino, all the leds of the strip turn white, i partially solved this problem by doing this
for(int i = 0; i < 34; i++) {
leds[i].setRGB( 0, 0, 0);
}
FastLED.show();
But as you can see in the video they still light up for like 2 or 3 sec then turn off because of the code.
I saw a lot of tutorials in youtube and they all seem to stay off on power on, unlike mine that turn on, when power is supplied.
There is no problem now, but i need to connect a lot more leds and the little step down that i have only supports 3A MAX, so you see the problem, on power on if i have a lot of leds they will turn on and something will go wrong.
So i need to ask you, how can i make the leds stay off when power is supplied and just light up when i say so in the code?
Here is a video of it working and the code
#include <FastLED.h>
#define NUM_LEDS 33
#define DATA_PIN A3
CRGB leds[NUM_LEDS];
unsigned long time;
String ciclos;
String intervalo;
String unoR;
String unoG;
String unoB;
String dosR;
String dosG;
String dosB;
String tresR;
String tresG;
String tresB;
char letra;
int ciclosI;
int intervaloI;
int unoIR;
int unoIG;
int unoIB;
int dosIR;
int dosIG;
int dosIB;
int tresIR;
int tresIG;
int tresIB;
int uno;
int dos;
int tres;
int check;
//////////////
void setup() {
Serial.begin(9600);
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
for(int i = 0; i < 34; i++) {
leds[i].setRGB( 0, 0, 0);
}
FastLED.show();
}
//////////////
void loop() {
check = 1;
if (Serial.available() > 0) {
delay(100);
while (Serial.available()) {
ciclos = Serial.readStringUntil(',');
Serial.read();
intervalo = Serial.readStringUntil(',');
Serial.read();
unoR = Serial.readStringUntil(',');
Serial.read();
unoG = Serial.readStringUntil(',');
Serial.read();
unoB = Serial.readStringUntil(',');
Serial.read();
dosR = Serial.readStringUntil(',');
Serial.read();
dosG = Serial.readStringUntil(',');
Serial.read();
dosB = Serial.readStringUntil(',');
Serial.read();
tresR = Serial.readStringUntil(',');
Serial.read();
tresG = Serial.readStringUntil(',');
Serial.read();
tresB = Serial.readStringUntil(')');
}
unoIR = unoR.toInt();
unoIG = unoG.toInt();
unoIB = unoB.toInt();
dosIR = dosR.toInt();
dosIG = dosG.toInt();
dosIB = dosB.toInt();
tresIR = tresR.toInt();
tresIG = tresG.toInt();
tresIB = tresB.toInt();
intervaloI = intervalo.toFloat()/80;
ciclosI = ciclos.toInt();
for(int c = 1; c = ciclosI; c++) {
for(int i = 0; i < 32; i++) {
if(i==0){
uno = unoIR/40;
dos = unoIG/40;
tres = unoIB/40;
}
if(i==9){
uno = dosIR/40;
dos = dosIG/40;
tres = dosIB/40;
}
if(i==17){
uno = tresIR/40;
dos = tresIG/40;
tres = tresIB/40;
}
if(i==0 && check == 1){
for(int d = 1; d < 41; d++) {
leds[i].setRGB( uno*d, dos*d, tres*d);
FastLED.show();
time = millis();
while(millis() - time < intervaloI){
if (Serial.available() > 0) {
letra = Serial.read();
}
if(letra=='A'){
break;
}
}
if(letra=='A'){
break;
}
}
check = 0;
}
if(letra=='A'){
leds[i].setRGB( 0, 0, 0);
leds[i+1].setRGB( 0, 0, 0);
break;
}
for(int d = 1; d < 41; d++) {
if ( i!=9 && i!=17){
leds[i].setRGB( uno*(40-d), dos*(40-d), tres*(40-d));
}
if ( i==9){
leds[i].setRGB( unoIR*(40-d)/40, unoIG*(40-d)/40, unoIB*(40-d)/40);
}
if ( i==17){
leds[i].setRGB( dosIR*(40-d)/40, dosIG*(40-d)/40, dosIB*(40-d)/40);
}
if ( i==31 && (ciclos-c)!=0){
leds[0].setRGB( unoIR*d/40, unoIG*d/40, unoIB*d/40);
}
leds[i+1].setRGB( uno*d, dos*d, tres*d);
FastLED.show();
time = millis();
while(millis() - time < intervaloI){
if (Serial.available() > 0) {
letra = Serial.read();
}
if(letra=='A'){
break;
}
}
if(letra=='A'){
break;
}
}
if(letra=='A'){
leds[i].setRGB( 0, 0, 0);
leds[i+1].setRGB( 0, 0, 0);
break;
}
time = millis();
if(i>0){
while(millis() - time < intervaloI){
if (Serial.available() > 0) {
letra = Serial.read();
}
if(letra=='A'){
break;
}
}
}
if(letra=='A'){
leds[i].setRGB( 0, 0, 0);
leds[i+1].setRGB( 0, 0, 0);
break;
}
}
if(letra=='A'){
break;
}
}
}
FastLED.show();
intervalo="";
letra='C';
}