I am having issues with the attached sketch. I want one jewel to be flashing clockwise (Led 0-6) and the other counterclockwise (led 13-7). I have tried 2 method. connected in series to use 1 pin on board and connected to separate pins onboard. The current sketch rotates both in the clockwise direction. I am at a loss. I believe the main issue is in the "void setup" I may need to do some work in the loop as well
Star Trek Bussards:
//=======for the Neopixel Jewel=========
#include <FastLED.h>// include library
#define NUM_LEDS 7 // number of leds
#define DATA_PIN 5 //signal pin of board
#define DATA_PIN2 3
#define MASTER_BRIGHTNESS 50
CRGB leds[NUM_LEDS];//setup individual clockwise led array
CRGB ledsR[NUM_LEDS];//setup individual counterclockwise led array
//=======for the Neopixel========
const unsigned long nacOnTime = 100; //each pixel on time
const unsigned long nacOffTime = 50; //each pixel off time
unsigned long nacInterval = nacOffTime;
unsigned long nacPreviousMillis;
unsigned long currentMillis = millis();
bool nacState;
int nacCount;
CRGB fixedColor[NUM_LEDS] =
{
CRGB::Red,//led 0
CRGB::Blue,//led 1
CRGB::Yellow,//led 2
CRGB::Green,//led 3
CRGB::Orange,//led 4
CRGB::Magenta,//led 5
CRGB::Violet,//led 6
};
CRGB fixedColor2[NUM_LEDS] =
{
CRGB::Red,//led 0
CRGB::Blue,//led 1
CRGB::Yellow,//led 2
CRGB::Green,//led 3
CRGB::Orange,//led 4
CRGB::Magenta,//led 5
CRGB::Violet,//led 6
};
void setup() {
// FastLED.setBrightness(MASTER_BRIGHTNESS); // full brighness is better for Wokwi
// start the strip and blank it out
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); //declare first LED strip
FastLED.addLeds<NEOPIXEL, DATA_PIN2>(leds, NUM_LEDS); //declare first LED strip
//Select led colors. these will not require random changing
for ( int i = 0; i < NUM_LEDS; i++) {
CRGB ledsR[NUM_LEDS - 1 - i] = leds[i];
leds[i] = fixedColor[i];
//ledsR[i]= fixedColor2[i]; (this line caused the full strips to light and stay on)
}
FastLED.show();
delay( 2000);
FastLED.clear();
}
void loop() {
currentMillis = millis();
NacLed();
}
// not sure where to go here
// i want pixel zero to be high for 100ms-low for 50ms, pixel 1 hinh for 100ms-low for 50ms etc.
// each pixel having a set indivdual color
void NacLed()
{
if ( currentMillis - nacPreviousMillis >= nacInterval)
{
nacPreviousMillis = currentMillis;
if ( nacState)
{
// Turn the led off by making it black.
leds[nacCount] = CRGB::Black;
nacState = false;
nacInterval = nacOffTime;
// Done with this led, set the next led
nacCount++;
if ( nacCount >= NUM_LEDS)
nacCount = 0;
}
else
{
leds[nacCount] = fixedColor[nacCount]; // set this led to its own color
nacState = true;
nacInterval = nacOnTime;
}
FastLED.show();
}
}