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.
9 years, 8 months ago.
how to make another LED blink using mbed nxp lpc1768 and also explain the code.
modify this following code and explain the newer
- include "mbed.h"
DigitalOut myled(LED1);
int main() { while(1) { myled = 1; wait(0.2); myled = 0; wait(0.2); } }
1 Answer
9 years, 8 months ago.
You should try something like this ...
Another led test
#include "mbed.h"
DigitalOut myled(LED1);
DigitalOut mysecondled(LED2); // name LED2 pin output as mysecondled
DigitalOut mythirdled(LED3); // etc
DigitalOut lastled(LED4); // etc
int main() {
while(1) {
myled = 1; // like initial demo, light first led ON
wait (0.5);
mysecondled = 1; // light next LED
wait(0.5);
mythirdled = 1; // light third one !
wait(0.5);
lastled = 1; // now all 4 leds should be BRIGHT ON !
wait(2); // lets make a short break ...
myled = 0; // after 2 sec , start turning everything OFF ...
mysecondled = 0;
mythirdled = 0;
lastled = 0;
wait(1); // after 1 sec , repeat the while loop
}
}
Why?
posted by Paul Staron 04 Mar 2016because I am new to this and very much interested.
posted by Prashant Kumar 05 Mar 2016Looks like a homework question to me.
posted by Paul Staron 05 Mar 2016