I've just started learning how to program with Arduino, so I don't know exactly what I'm doing 100% of the time. Currently I have a goal in mind
The one I'm working on is trying to get two colors to move across the led strip. Similar to the way movie lights move. This one I do have code for. It gets the idea across of what I want it to do, I just don't know how to connect the code to show up at the same time and how to get it to move.
#include <FastLED.h>
#define DATA_PIN 2
#define NUM_LEDS 300
#define BRIGHTNESS 10
#define LED_TYPE WS2812B
#define COLOR_ORDER RGB
// Define the array of leds
CRGB leds[NUM_LEDS];
#define UPDATES_PER_SECOND 10
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
}
void loop(){
moving_three_led();
}
void moving_three_led(){
for (int i=0; i<NUM_LEDS; i++){
if ((i % 2) == 0){leds[i] = CRGB(255, 0, 90);}
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Black;
}
for (int i=0; i<NUM_LEDS; i++){
if ((i % 2) == 1){leds[i] = CRGB(0, 255, 190);}
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++){
leds[i] = CRGB::Black;
}
}
Any help is appreciated
This is the example that I drew up
#include <FastLED.h>
#define DATA_PIN 2
#define NUM_LEDS 300
#define BRIGHTNESS 20
#define LED_TYPE WS2812B
#define COLOR_ORDER RGB
// Define the array of leds
CRGB leds[NUM_LEDS];
#define UPDATES_PER_SECOND 10
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
static byte StartPoint = 0;
moving_three_led(StartPoint);
delay(500);
StartPoint = (++StartPoint) % 3;
}
void moving_three_led(byte offset) {
for (int i = offset; i < NUM_LEDS; i += 3) {
leds[i] = CRGB(255, 0, 90);
}
for (int i = (offset + 1) % 3; i < NUM_LEDS; i += 3) {
leds[i] = CRGB::Black;
}
for (int i = (offset + 2) % 3; i < NUM_LEDS; i += 3) {
leds[i] = CRGB(0, 255, 190);
}
FastLED.show();
}
Thank you for the help. That's some code that I needed but didn't post about. I still haven't gotten the code that I wanted.
is this what you want?
#include <FastLED.h>
#define DATA_PIN 2
#define NUM_LEDS 300
#define BRIGHTNESS 20
#define LED_TYPE WS2812B
#define COLOR_ORDER RGB
// Define the array of leds
CRGB leds[NUM_LEDS];
#define UPDATES_PER_SECOND 10
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
static byte StartPoint = 0;
moving_led(StartPoint);
delay(500);
StartPoint = (++StartPoint) % 2;
}
void moving_led(byte offset) {
for (int i = 0; i < NUM_LEDS; i += 2) {
leds[i+offset] = CRGB(255, 0, 90);
leds[i+1-offset] = CRGB(0, 255, 190);
}
FastLED.show();
}
YES! Omg, thank you so much!
Ok! Thank you for the help through this process.