I am trying to do a simple code, and I am sure my issue is staring me right in the face but... I have an LED strip with 6 LED's. Trying to get them to light up in a certain order, being 1st led with 3rd, 2nd with 4th, 3rd with 5th.
So I create 3 arrays, butting the 2 leds in each. Everything cycles through just fine. However the first led, "leds[0]" stays lit no matter what I do. I have tried fastled.clear, I have tried just setting it to (0,0,0) but no matter what, that first led on the strip doesn't turn off like the rest do.
#include "FastLED.h"
#include <EEPROM.h>
#define NUM_LEDS 6
CRGB leds[NUM_LEDS];
#define DATA_PIN 6
int Arry1[NUM_LEDS] = {0, 3};
int Arry2[NUM_LEDS] = {1, 4};
int Arry3[NUM_LEDS] = {2, 5};
int i = 0;
void setup()
{
FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.clear();
}
void loop(){
FastLED.clear();
delay(500);
Ary1();
delay(500);
Ary2();
delay(500);
Ary3();
}
void Ary1(){
FastLED.clear();
for(int i = 0; i < NUM_LEDS; i++){
leds[Arry1[i]] = CRGB::Red;
FastLED.show();
}
}
void Ary2(){
FastLED.clear();
for(int i = 0; i < NUM_LEDS; i++){
leds[Arry2[i]] = CRGB::Red;
FastLED.show();
}
}
void Ary3(){
FastLED.clear();
for(int i = 0; i < NUM_LEDS; i++){
leds[Arry3[i]] = CRGB::Red;
FastLED.show();
}
}
int Arry1[NUM_LEDS] = {0, 3}; // <- this is same as {0, 3, 0, 0, 0, 0} in your case.
for(int i = 0; i < NUM_LEDS; i++){
Serial.printf(Arry1[i]);
}
//this should work
for(int i = 0; i < 2; i++){
Serial.printf(Arry1[i]);
}
No it did not work with the code you supplied. I am not sure what you mean by image of the setup, it's literally just an arduno nano, with an LED strip cut down to 6 led's. Ground to ground, power to 5v, digital to pin 6.
Here is the code I updated...
#include "FastLED.h"
#include <EEPROM.h>
#define NUM_LEDS 6
CRGB leds[NUM_LEDS];
#define DATA_PIN 6
int Arry1[NUM_LEDS] = {0, 3};
int Arry2[NUM_LEDS] = {1, 4};
int Arry3[NUM_LEDS] = {2, 5};
int i = 0;
void setup()
{
FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.clear();
Serial.begin(9600);
}
void loop(){
FastLED.clear();
delay(500);
Ary1();
delay(500);
Ary2();
delay(500);
Ary3();
}
void Ary1(){
FastLED.clear();
for(int i = 0; i < 2; i++){
leds[Arry1[i]] = CRGB::Red;
Serial.println(Arry1[i]);
FastLED.show();
}
}
void Ary2(){
FastLED.clear();
for(int i = 0; i < 4; i++){
leds[Arry2[i]] = CRGB::Red;
Serial.println(Arry2[i]);
FastLED.show();
}
}
void Ary3(){
FastLED.clear();
for(int i = 0; i < 6; i++){
leds[Arry3[i]] = CRGB::Red;
Serial.println(Arry3[i]);
FastLED.show();
}
}
You are saying that when you tried the examples for the led strip library LED0 did not work either? If this is the case the issue is not with your code. Thus, if you could take a picture of your setup and post it, the image may prove useful.