Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 10 months ago.
How do I change the LED blinking pattern in Blinky?
How do I change the LED to blink for 2 long flashes and then a short flash and then a pause of 2 seconds? What is the C++ code? This is what I have so far:
- include "mbed.h"
DigitalOut led1(LED1);
main() runs in its own thread in the OS int main() { while (true) { led1 = !led1; wait(2); } }
1 Answer
7 years, 10 months ago.
Your code
#include "mbed.h"
DigitalOut led1(LED1);
main()
{
while (true)
{
led1 = !led1;
wait(2);
}
}
What you wanted....
#include "mbed.h"
DigitalOut led1(LED1);
main()
{
while (true)
{
//First long flash
led1 = 1; //ON (assuming '1' = ON)
wait(2); //Long time (stay on for 2 seconds)
led1 = 0; //Off
wait(0.5);//Short time
//Second long flash
led1 = 1; //ON (assuming '1' = ON)
wait(2); //Long time
led1 = 0; //Off
wait(0.5);//Short time
//Short flash
led1 = 1; //ON (assuming '1' = ON)
wait(0.5); //Short time
led1 = 0; //Off
wait(0.5);//Short time
//Now wait 2 seconds
wait(2);
}
}
"What is the C++ code? " - hmmm....hope this C code above can help
Bill