9 years, 7 months ago.

Voltage on DigitalOut pin is reversed

I have a FRDM-KL25Z and I am trying to power up the on-board led (LED_BLUE). If I set it to 0 it is on and if I set it to 1 it is off. Why is that? Shouldn't it be 1 for ON and 0 for OFF? Sorry for newbie question.

1 Answer

9 years, 7 months ago.

The behaviour of the LEDs depends on how they are connected. When the LED anode is connected to the DigitalOut pin and the cathode is connected to ground (with a series resistor in between) it will light up when the pin level is at high voltage. That circuitry is used on the LPC1768 mbed. However, when the LED anode is connected to the powersupply and the cathode is connected to the DigitalOut pin (with a series resistor in between) it will light up when the pin level is at low voltage. This is the circuitry that is used on the FRDM mbed. So unfortunately the behaviour of the LED is inconsistent across different mbed modules. There has been a suggestion to add a #define to the mbed.h that provides names like LED_ON and LED_OFF which are automatically adapted depending on the mbed module, but that has not yet been done and may still not be failsafe solution.

Also note that on some boards the LEDs are connected to a pin that has other functions too. On the KL25Z the Blue LED is connected to PTD1, which is also the SCK pin of a SPI port. So the LED DigitalOut will influence the SPI port (and vice versa) when used at same time.