Basic LED circuit

08 Apr 2012

I'm new to using microcontrollers (just got LPC11U24), and I just had a (probably very basic) question to ask: I'm not entirely sure what to do with the Vin, Vout and Ground pins. From what I understand, the 3V connection (I have two AA batteries) is connected across the Vout and Ground pins, but I don't understand what the Vin is for!

I just wanted to build a basic circuit of LEDs controlled through the microcontroller - I'm fairly confident with the programming of it, it's just the connections that confuse me. Do I connect the LEDs across different pins, all connected to the Ground?

I realise that this is probably extremely easy, but I'm self-taught and just wanted to confirm the basics of using the microcontroller before risking it. Thanks in advance.

08 Apr 2012

Vout provides 3.3 Volts out whenever mbed is switched on. The mbed can be powered either through its USB cable or via an external supply. The external supply is provided on the Vin pin. It should be between 4.5v and 9 volts. Obviously, the GND pin is the common ground pin. External LEDs need to have the cathode on one of the mbed digital out pins. The LED anode should be connected to Vout with a 220 ohms series resistor. You can then switch on the LED by writing a '0' to the digital out pin.

10 Apr 2012

Thanks a lot, seems as if I had myself completely confused!

Siddharth

13 Apr 2012

I'm new to using microcontrollers LPC1768, I have followed the Win's suggestions but the LED does not works. I have measured the voltage between VOUT and GND and it's correct. I have measured the voltage between VU and GND and it's correct.

1)If I connect a led with the cathode on one of the mbed digital out pins and the anode to Vout: The Led is always turned off.

2)If I connect a led with the cathode on GND pin and anode one of the mbed digital out pins : The Led is always turned on.

But both cases are not what I want : turn on and turn off LED by a program.

Please let me know what I'm mistaking

wolf

14 Apr 2012

Conrad Conrad wrote:

1)If I connect a led with the cathode on one of the mbed digital out pins and the anode to Vout: The Led is always turned off.

Your DigitalOut is at logic 1 level (3V3). So both Anode and Cathode are 3V3 and the LED is always off.

Conrad Conrad wrote:

2)If I connect a led with the cathode on GND pin and anode one of the mbed digital out pins : The Led is always turned on.

Your DigitalOut is at logic 1 level (3V3). So Anode is positive and Cathode is at GND and the LED is always on.

Turning the LED on and off is done by toggling the DigitalOut pin between 1 and 0. Don't forget the series resistor! You will damage the LED and/or mbed when it is missing.

Use a bit of code like this

#include "mbed.h"

DigitalOut myled(p21);  /// Connect LED cathode to pin 21

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

You need to check your output pin if the LED still has the same behaviour when you run the above code. Check that you have the correct pin connected to the LED. Measure the voltage on the DigitalOut pin without the LED. Maybe the output is damaged and stuck at 3V3.

14 Apr 2012

Hi Wim, thanks for your reply. I have followed your suggestion but still no works:

I have connected LED cathode to pin 21 and the other end to gnd by a resistor of 220ohm value.

- the voltage on the DigitalOut pin without the LED is always 2V2 - all DigitalOut pins has this voltage.

The mbed is new so I hope that is not damaged. :(

many thanks Wolf

14 Apr 2012

Try reversing the LED. Cathode equals negative side, and anode equals positive.

You can drive the LED directly from the mbed, and with about 4mA for non-highbright LED's, it should light up.

p21 -> Anode of LED

Cathode of LED -> Resistor

Resistor -> GND

This should make it light up

14 Apr 2012

Conrad Conrad wrote:

I have connected LED cathode to pin 21 and the other end to gnd by a resistor of 220ohm value.

This can not work. The other end of the LED should go to 3V3 via the series resistor. The reason is that anode has to be positive with respect to the cathode to allow any current to flow.

I find it strange that your output pin is always 2v2. Are you sure you have the right pin. Are you sure the testprogram has been loaded and is running. Add some printf and toggle one of the onboard LEDs in sync with DigitalOut pin..

21 Apr 2012

After unmounted and reset the mbed It's works. Many thanks.