#include <FastLED_NeoPixel.h>
#define MAX_P 30
#define BUTTON_PIN 8
CRGB leds[MAX_P];
Adafruit_NeoPixel strip = Adafruit_NeoPixel(MAX_P, 3, NEO_BRG + NEO_KHZ800);
int potPin0 = 0;
int potPin1 = 1;
int val0 = 0;
int val1 = 0;
int li = 0;
int direction = 1;
uint32_t Red = strip.Color(255, 0, 0);
uint32_t Blank = strip.Color(0, 0, 0);
unsigned long buttonPressTime = 0;
void setup() {
pinMode(8, OUTPUT);
strip.begin();
strip.show();
}
void loop() {
digitalWrite (8, LOW);
// digitalWrite(8, HIGH); // Here the trigger is pulled high permanently
if (millis() - buttonPressTime >= 1000 && millis() - buttonPressTime <= 1000) {
digitalWrite(8, HIGH); // not working ?
}
val0 = analogRead(potPin0) / 50; // for 100k pot speed
val1 = analogRead(potPin1) / 34.1; // for 100k pot tail
//decay
for(uint16_t i=0; i<MAX_P; i++) {
uint8_t r= (strip.getPixelColor(i)>>16) & 0xff;
r=(r*(69+val1))/100;
strip.setPixelColor(i, r, 0, 0);
}
strip.setPixelColor(li, Red);
if(li>(MAX_P-1)){
li=MAX_P;
direction=-1;
}else if(li<0){
li=-1;
direction=1;
}
li+=direction;
strip.show();
delay(val0);
buttonPressTime = millis(); // Record the time for the button press
}