Arduino mega with a 2.4 screen and a sting of leds.. The arduino receives an option from another unit 1-4 and it updates the screen and blinks the lcd to show option picked.. This is all working but the lights only blink twice.. I am using the int LedStat that is set through parseInt to pick which case to go through and also blink leds.. From what I am thinking if LedStat=1 it will run case 1 and longpressblink1 should run until it is changed.. I have tried using a different int set through the case but the results were the same
void loop() {
Serial1.begin (9600);
Serial.setTimeout(1000000);
while (Serial1.available() == 0){
}
LedStat = Serial1.parseInt();
blinks();
switch (LedStat){
case 1:
longPressStart1();
break;
case 2:
longPressStart2();
break;
case 3:
longPressStart3();
break;
case 4:
longPressStart4();
break;
}
}
void blinks (){
if (LedStat ==1) LongPressBlink1();
if (LedStat ==2) LongPressBlink2();
if (LedStat ==3) LongPressBlink3();
if (LedStat ==4) LongPressBlink4();
}
// This function will be called once, when the button1 is pressed for a long time.
void longPressStart1() {
Serial.println("Button 1");
tft.fillScreen(BLACK);
tft.setTextColor(RED, GREY);
tft.setTextSize(5);
tft.setCursor(50, 120);
tft.print("Button 1 longpress");
fill_solid (leds, NUM_LEDS, CRGB(255, 0, 0));
FastLED.show();
delay(500);
// Now turn the LED off, then pause
fill_solid (leds, NUM_LEDS, CRGB (0, 0, 0));
FastLED.show();
delay(500);
LongPressBlink1();
}
void LongPressBlink1 ()
{
fill_solid (leds, NUM_LEDS, CRGB(255, 0, 0));
FastLED.show();
delay(500);
// Now turn the LED off, then pause
fill_solid (leds, NUM_LEDS, CRGB (0, 0, 0));
FastLED.show();
delay(500);
}