Hope everyone is doing well. I am very new to arduino, but am fascinated by its many uses. I'm currently working on a school project where i have to build logic gate circuits. I have managed to get the street lights to work via AND and OR gates. Now i want to represent vehicles in roads with two different color leds one car will be Yellow the other will be blue. Doing research i have started building the code , but i don't know if its efficient and it's not working like i wish it would. i want the leds to start in different positions on the strip and adjust the speed they travel. At all times only two leds will be on (one yellow, one blue) while changing positions hence representing cars in an intersection. Additionally i was wondering if their is a way to make the leds stop at a red light (make it comunicate with the OR circuit when its HIGH to stop). Thanks in Advance!
I am Currently using WS2812B RGB Led Strip
code:
#define NUM_LEDS 14
#define COLOR_ORDER GRB
#define ledpin 7
#include <FastLED.h>
struct CRGB leds[NUM_LEDS];
void setup() {
// put your setup code here, to run once:
delay(1000);
FastLED.addLeds<WS2812B, ledpin, GRB>(leds, NUM_LEDS);
}
void loop() {
// put your main code here, to run repeatedly:
for(int i=0;i<NUM_LEDS;i++){
leds[i-2].setRGB( 0, 0, 0);
leds[i].setRGB( 255, 255, 0);
FastLED.show();
delay(200);
}
FastLED.clear();
}