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

Coating chocolate using methods like panning

 Coating chocolate using methods like panning involves careful temperature control throughout the processing period to achieve the desired r...

Popular Posts