I am using ws2812b's, an arduino uno and a button.
I need the light strip to get a pulse of light to go down and then back up the strip every time the button is pressed and have this continue in a loop. every time the button is pressed a new pulse starts while the previous pulse stays
eg: button pressed --> light pulse goes up and down strip --> button pressed again --> now there are two pulses on the strip.
I undertsand that I have to set a limit on the amount of pulses which can run before a reset but am fine with what ever the max is and do not know how to determine what it will be.
I was going to use if and for loops but i found a code i think i can use if i modify it using the fastled library:
#include<FastLED.h>
#define NUM_LEDS 30
#define SCROLL_SPEED 50
CRGBArray<NUM_LEDS> leds;
int INpin = 7;
int input = 0;
unsigned long lastUpdate;
void setup() {
FastLED.addLeds<NEOPIXEL, A0>(leds, NUM_LEDS);
pinMode(INpin, INPUT);
}
void loop() {
input = digitalRead(INpin);
if (input == HIGH)
leds[0] = CRGB::Blue;
else
leds[0] = CRGB::Black;
if (millis() - lastUpdate > SCROLL_SPEED) {
lastUpdate += SCROLL_SPEED;
for (int i = NUM_LEDS - 1; i > 0; i--)
leds = leds[i - 1];
FastLED.show();
}
}
Does anyone have any suggestions of how I should modify it.
I am very new to coding and the project is due soon so any advice/help would be extremely appreciated.