PHP

11/21/2023

ESP32 Builkt-in LED Blink by using millis() [002]

 //Using Millis() for LED ON and OFF


int ledPin = 2;  // ESP 32 

int ledState = LOW;

long interval = 1000;

long previousMillis = 0;


void setup() {

pinMode(ledPin,OUTPUT);

}


void loop() {

  unsigned long currentMillis = millis();

  if( currentMillis - previousMillis > interval ) {

      previousMillis = currentMillis;

      if( ledState == LOW ) {

        ledState = HIGH;

        }

       else {

        ledState = LOW;

        }

      digitalWrite(ledPin,ledState);

      }

  }

No comments:

Post a Comment

Featured Post

php db connect

  <?php echo "Hello world!" ; $server_name = "localhost" ; $user = "root" ; $password = "" ; ...

Popular Posts