Programming Pandit

c/c++/c#/Javav/Python


Latest Update

Sunday, September 22, 2024

Arduino program to ‘turn ON’ LED for 1 sec after every 2 seconds

 

 Objective: To interface LED/Buzzer with Arduino Uno and write a program to ‘turn ON’ LED for 1 sec after every 2 seconds.

Code:


// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(12, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(12, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(2000);                      // wait for a second
  digitalWrite(12, LOW);   // turn the LED off by making the voltage LOW
  delay(2000);                      // wait for a second
}

Output:



No comments:

Post a Comment