blinking led within an if serial function

Hello,

below my code. It’s a simple project, 3 buttons give commands to a pc prog, the same prog gives simple commands (0 and 1) to the microcontroller. 2 LED’s and an LCD display are added for visual confirmation for what the pc program is doing.
Everything works except, I want an red LED to be blinking when the PC gives the command through the serial port (usb).

In this case the pc gives the 1 command, and then the red LED should start blinking.
What am I doing wrong?

  /*
 * Button.pde
 */
 
#include <LiquidCrystal.h>


const int ledgroen = 21; // pin the LED is connected to, voorlopig de onboard LED
const int ledrood = 20; // rode LED

int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated
long interval = 1000;
int ledstatus = LOW;



// Connecties LCD display:
// rs (LCD pin 4) to teensy pin 13
// rw (LCD pin 5) to ground
// enable (LCD pin 6) to teensy pin 12
// LCD pin 15 to teensy pin 19 (achtergrondverlichting display)
// LCD pins d4, d5, d6, d7 to teensy pins 15, 16, 17, 18
LiquidCrystal lcd(13, 15, 12, 15, 16, 17, 18);
int backLight = 19;    // pin 19 will control the backlight



void setup() {
  Serial.begin(9600);      // Initialize serial port to send and receive at 9600 baud
  lcd.begin(16,2);              // columns, rows.  use 16,2 for a 16x2 LCD, etc.
  pinMode(ledgroen, OUTPUT); // set this pin as output
  pinMode(ledrood, OUTPUT);
  pinMode(backLight, OUTPUT);

  pinMode(10, INPUT_PULLUP);    // knop op pin 10. ( spatieknop)
  pinMode(9, INPUT_PULLUP);   // knop op pin 9.( - knop)
  pinMode(4, INPUT_PULLUP);   // knop op pin 4 (+ knop)
  delay(4000);
}

void loop() {
  if (digitalRead(10) == HIGH) {   //lees de knop uit
    delay(10);
  } else {
    Keyboard.println(" "); // we print a space
    delay(100);
    
  }
  delay(10);
  
  if (digitalRead(9) == HIGH) {   //lees de knop uit
    delay(10);
  } else {
    Keyboard.println("-"); // we printen de - knop
    delay(100);
  }
  delay(10);
  
  if (digitalRead(4) == HIGH) {   //lees de knop uit
    delay(10);
  } else {
    Keyboard.println("+"); // we print +
    delay(100);
  }
  delay(10);
  
    unsigned long currentMillis = millis();
   if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;  

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;
      bitWrite(ledstatus, 0, ledState);
  }  
  
  //hieronder code voor LED & LCD
  if ( Serial.available()) // Check to see if at least one character is available
  {     
    
    char ch = Serial.read();
    
    if(ch == '1') // 
    {
       

      digitalWrite(ledrood, ledstatus);

      digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
       digitalWrite(ledgroen,LOW);
         if (Serial.available()) {
      delay(1); //wachten tot boodschap is gearriveerd
      lcd.clear(); //maak LCD leeg
      lcd.setCursor(0,0);
      while (Serial.available() > 0) { //geef alles weer dat meer is dan 0
      lcd.write(Serial.read());  // display each character to the LCD
    }
         }
       
    }
    
    else if(ch == '0')
    {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.write("Opname gedaan!");
      lcd.setCursor(0,1);
      lcd.write("Bedankt!");
      delay(5000);
      lcd.clear();
      digitalWrite(ledgroen,HIGH);
      digitalWrite(backLight, LOW);
      digitalWrite(ledrood, LOW);
      
    }
       
  }
  
}

Thanks alot for the replies!

What am I doing wrong?

You are using delay() that stops the processor from doing anything.
If you want continuous blinking once a certain event has occurred you need to write the code as a state machine. Look at the blink without delay example in the IDE. That is a simple state machine.

It looks like you’re using bitWrite where digitalWrite would be more appropriate.