How to serial read blinking led?

Hi, I have a wireless charger & it has two LEDs- RED & BLUE. I connected Arduino to it so I can check status on the serial monitor.

Now it's showing me when it's charging, charged, error or not charging.

But how can I read blinking led?

|500x281

const int red = 34;     
const int blue = 35;     


int buttonState_red = 0;         
int buttonState_blue = 0;         

void setup() {
  Serial.begin(9600);     
  pinMode(red, INPUT);
  pinMode(blue, INPUT);
}

void loop() {

  buttonState_red = digitalRead(red);
  buttonState_blue = digitalRead(blue);


  if (buttonState_red == LOW) {
    Serial.print("ERROR\n");     
  } 
  
  else if (buttonState_blue == LOW) {
    Serial.print("CHARGING\n");   
  }

  else if (buttonState_blue && buttonState_red == LOW) {
    Serial.print("CHARGED\n");   
  }
  
  else {
   Serial.print("NOT CHARGING\n");     
  }
}

bujna94: Now it's showing me when it's charging, charged, error or not charging.

But how can I read blinking led?

Do you mean that you want the Arduino to use something like a photo-transistor to detect when the coloured LEDs are lighting and not-lighting and use that info to identify the state of the charger?

If not. what do you want the Arduino to do?

...R

But how can I read blinking led?

You aren't reading the LEDs. You are reading the state of the power source driving the LED. A flashing LED means that the power source is being turned on and off, at regular intervals.

You need to know the current state of the pin and the previous state of the pin, and when the states change. If the state doesn't change, then the LED is steady on or steady off. If it does change regularly, then the LED is flashing. You'll need to determine what regularly means - once a second, twice a second, etc. If the state changes less often, then it isn't in a fault condition (or whatever the last two columns mean).