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, 1 month ago.
2 LED Blinky weird behaviour
Got an LPC800-Max board.
Instead of blue and green blinking after each other with a 1 second black gap, in the 1 second gap both leds are on (sequence is blue lightblue green lightblue in a loop) I can't explain this so please try to explain.. :/
#include "mbed.h" DigitalOut ledB(LED1); DigitalOut ledG(LED2); int main() { while(1) { ledB = 1; wait(1); ledB = 0; wait(1); ledG = 1; wait(1); ledG = 0; wait(1); } }
2 Answers
7 years, 1 month ago.
That sounds correct. This is your code but using "OFF" and "ON" to help explain..
#include "mbed.h" DigitalOut ledB(LED1); DigitalOut ledG(LED2); #define OFF 1 #define ON 0 int main() { while(1) { ledB = OFF; wait(1); ledB = ON; wait(1); ledG = OFF; wait(1); ledG = ON; wait(1); } }
7 years, 1 month ago.
Are your LED pins active low? It's quite common to wire LEDs up so that you output 0 to turn them on and 1 to turn them off.