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.
8 years, 3 months ago.
Silly problem with LPCExpresso4337
when setting only one of RED,BLUE,GREEN to 1 the led works as expected. if two or more of RED,GREEN,BLUE are selected, I expect to see some period of time when all leds are off. But I do not see this, instead, I see both leds on and get some blend of colors. Another point, just using the standard blinky project and creating a blue object will mess up the red led. I looked at the schematic but it does not show anything weird. any thoughts?
led issue
include "mbed.h" #define RED 1 #define BLUE 0 #define GREEN 1 #if RED == 1 DigitalOut red(LED1); #endif #if BLUE == 1 DigitalOut blue(LED2); #endif #if GREEN == 1 DigitalOut green(LED3); #endif int main() { float d = 0.9; while(1) { #if RED == 1 red = 1; wait(d); red = 0; wait(d); #endif #if BLUE == 1 blue = 1; wait(d); blue = 0; wait(d); #endif #if GREEN == 1 green = 1; wait(d); green = 0; wait(d); #endif } }
1 Answer
8 years, 3 months ago.
The LED will be on when you pull the pins low since the anodes are connected to 3V3. So everything is just in reverse: for some period of time all pins will be low, so all LEDs are on! The pins are never all high at same time, so the LEDs will never be all off.