Hello, i'm new to arduino. I want to make a running led for my bike tail
#include "Arduino.h"
#include <FastLED.h>
#define LED_PIN 2 //LED Strip Signal Connection
#define BrakeSignal 8 //Brake Signal Connection
#define LeftSignal 6 //Left Blinker Signal Connection
#define RightSignal 7 //Right Blinker Signal Connection
#define NUM_LEDS 74 //Total no of LEDs in the LED strip
#define BlinkerLEDs 13 //LEDs for Left/Right Blinker
int l,j;
int bright = 30;
byte *c;
uint16_t a, b = 0;
int r = NUM_LEDS;
//int BlinkerSpeed = 5; //Blinker Running LED Speed. Adjust this to match with your Bike blinker speed.
int BlinkerOffDelay = 300; //Blinker Off time. Adjust this to match with your Bike blinker speed.
unsigned long tAwal;
unsigned long tLsein;
unsigned long tRsein;
unsigned long tSekarang;
CRGB leds[NUM_LEDS];
void setup()
{
Serial.begin(9600);
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
pinMode(BrakeSignal, INPUT);
pinMode(LeftSignal, INPUT);
pinMode(RightSignal, INPUT);
for (int i = 0; i < (NUM_LEDS/2); i++)
{
leds[i] = CRGB(60, 0, 0);
leds[i-1] = CRGB(0, 0, 0);
leds[(NUM_LEDS-1)-i] = CRGB(60, 0, 0);
leds[(NUM_LEDS)-i] = CRGB(0, 0, 0);
FastLED.show();
delay (50);
}
for (int j = ((NUM_LEDS/2)-1); j >= 0; j--)
{
leds[j] = CRGB(60, 0, 0);
leds[(NUM_LEDS/2-1)+((NUM_LEDS/2)-j)] = CRGB(60, 0, 0);
FastLED.show();
delay (50);
}
for (int i = 0; i < 5; i++)
{
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(0, 0, 0);
}
FastLED.show();
delay (75);
for (int i = 0; i < NUM_LEDS; i++)
{
leds[i] = CRGB(60, 0, 0);
}
FastLED.show();
delay (50);
}
LeftDim();
RightDim();
}
void loop()
{
tSekarang = millis();
if(digitalRead(LeftSignal)==1){
if (tLsein == 0){
tLsein = millis();
}else{
if (tSekarang - tLsein >= 50UL){
if (l <= (BlinkerLEDs-1)){
leds[l] = CRGB(255, 150, 0);
l++;
tLsein = tSekarang;
}else{
for (int j = 0; j <= (BlinkerLEDs-1); j++){
leds[j] = CRGB(0, 0, 0);
}
l = 0;
}
FastLED.show();
FastLED.setBrightness(bright);
}
}
}
if(digitalRead(LeftSignal)==0){
tLsein = 0;
for (int j = 0; j <= (BlinkerLEDs-1); j++){
leds[j] = CRGB(0, 0, 0);
}
FastLED.show();
l=0;
}
if(digitalRead(RightSignal)==1){
if (tRsein == 0){
tRsein = millis();
}else{
if (tSekarang - tRsein >= 50UL){
if (r >= (NUM_LEDS - BlinkerLEDs)){
leds[r] = CRGB(255, 150, 0);
r--;
tRsein = tSekarang;
}else{
for (int j = NUM_LEDS; j >= (NUM_LEDS - BlinkerLEDs); j--){
leds[j] = CRGB(0, 0, 0);
}
r = NUM_LEDS;
}
FastLED.show();
FastLED.setBrightness(bright);
}
}
}
if(digitalRead(RightSignal)==0){
tRsein = 0;
for (int j = NUM_LEDS; j >= (NUM_LEDS - BlinkerLEDs); j--){
leds[j] = CRGB(0, 0, 0);
}
FastLED.show();
r = NUM_LEDS;
}
if (tSekarang - tAwal >= 15UL){
if (digitalRead(BrakeSignal)==1){
for (int i = BlinkerLEDs; i < (NUM_LEDS - BlinkerLEDs); i++){
leds[i] = CRGB(255, 0, 0);
}
FastLED.show();
FastLED.setBrightness(bright);
}else{
for(a=NUM_LEDS/2; a > BlinkerLEDs; a--) {
c = Wheel(((a * 256 / (NUM_LEDS/2)) + b) & 255);
leds[(NUM_LEDS) - a].setRGB(*c, *(c+1), *(c+2));
leds[(NUM_LEDS - 1) - (NUM_LEDS - a)].setRGB(*c, *(c+1), *(c+2));
}
FastLED.show();
FastLED.setBrightness(bright);
tAwal = tSekarang;
b++;
}
}
}
void rainbowCycle(int Delay) {
byte *c;
uint16_t i, j;
for(j=0; j < 256; j++) {
if (tSekarang - tAwal >= Delay){
for(i=NUM_LEDS/2; i > BlinkerLEDs; i--) {
c = Wheel(((i * 256 / (NUM_LEDS/2)) + j) & 255);
leds[(NUM_LEDS) - i].setRGB(*c, *(c+1), *(c+2));
leds[(NUM_LEDS - 1) - (NUM_LEDS - i)].setRGB(*c, *(c+1), *(c+2));
}
FastLED.show();
tAwal = millis();
}
}
}
byte *Wheel(byte WheelPosition) {
static byte c[3];
if(WheelPosition < 85) {
c[0] = WheelPosition * 3;
c[1] = 255 - WheelPosition * 3;
c[2] = 0;
}
else if(WheelPosition < 170) {
WheelPosition -= 85;
c[0] = 255 - WheelPosition * 3;
c[1] = 0;
c[2] = WheelPosition * 3;
}
else {
WheelPosition -= 170;
c[0] = 0;
c[1] = WheelPosition * 3;
c[2] = 255 - WheelPosition * 3;
}
return c;
}
void LeftDim()
{
for (int i = 0; i < BlinkerLEDs; i++)
{
leds[i] = CRGB(0, 0, 0);
}
FastLED.show();
}
void RightDim()
{
for (int i = (NUM_LEDS - BlinkerLEDs); i < NUM_LEDS; i++)
{
leds[i] = CRGB(0, 0, 0);
}
FastLED.show();
}
but everytime it loops, the variable l on LeftSignal always become 0. But when I remove the Rigthsignal function, It run smoothly. I cant understand what happen
Please Help