Write a simple Arduino program to blink a LED with 500 msec. delay in between On and off.
Answers
Answer:
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Explanation:
Answer:
Concept
First of all understand the concept.
void setup(): put your setup code here, to run once.
void loop(): put your main code here, to run repeatedly.
Coding
// program of blinking of LEDs
void setup()
{
pinMode(8, OUTPUT);
}
void loop()
{
digitalWrite(8, HIGH);
delay(500);
digitalWrite (8, LOW);
delay(500);
}
Note : Here, 500 is the time duration in milliseconds.