Ahoy there! A newbie here, just playing around with Arduino for the first time. I'm trying to figure out how to make my LED double blink, kind of like a heartbeat? Please could anyone show me how to do that, or put me in the right direction?
Thanks for any help you can give! I posted the code below.
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
This probably belongs in a different forum, but here's your answer:
replace this:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
with this:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(400); // wait for 400ms
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for 100ms
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for 500ms
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
This particular pattern will blink twice within one second (with the second blink slightly longer than the first, like a heartbeat), then be off for a full second. I haven't tested it but it should be pretty close to a heartbeat style blink. Just play with the delays until you get the pattern you want. Enjoy!