User Tools

Site Tools


blinkingled
  loop(){
     ...codes...
      digitalWrite(BUILTIN_LED, (millis() / 1000) % 2);
  }

This code creates a blinking LED effect that toggles on and off every second.

Let me break it down: What it does:

    Makes an LED blink with a 1-second ON, 1-second OFF pattern

    The LED turns ON for 1 second, then OFF for 1 second, repeating continuously

How it works:

    millis() / 1000 - Converts milliseconds to seconds

    % 2 - Gets the remainder when divided by 2 (result alternates between 0 and 1)

    digitalWrite(STATUS_LED, ...) - Sets the LED state (HIGH/LOW)  
blinkingled.txt · Last modified: by jwan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki