8 years, 1 month ago.

how to make another LED blink using mbed nxp lpc1768 and also explain the code.

modify this following code and explain the newer

  1. include "mbed.h"

DigitalOut myled(LED1);

int main() { while(1) { myled = 1; wait(0.2); myled = 0; wait(0.2); } }

Why?

posted by Paul Staron 04 Mar 2016

because I am new to this and very much interested.

posted by Prashant Kumar 05 Mar 2016

Looks like a homework question to me.

posted by Paul Staron 05 Mar 2016

1 Answer

8 years, 1 month 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
    }
}

Accepted Answer