0
\$\begingroup\$

I'm in the process of transitioning from Arduino work to just using bare microcontrollers, and I've got a question that might be quite basic (but I've searched around and haven't found an answer for it yet).

I have an LED that I know should be quite bright when powered--and is when hooked up to an Arduino--but is very dim when hooked into an atmega328 pin. I'm powering the chip through the SparkFun Pocket AVR Programmer, and the LED is being powered through a resistor.

Is the voltage output from the atmega when powered by the programmer much lower than that of an Arduino? Am I doing something wrong?

\$\endgroup\$
2
  • \$\begingroup\$ The programmer you uses powers the target from the USB 5v. It also has an on/off switch. Make sure the switch is on. \$\endgroup\$
    – Passerby
    Oct 21 '13 at 11:04
  • \$\begingroup\$ The switch is on, powering the target. \$\endgroup\$ Oct 22 '13 at 4:26
0
\$\begingroup\$

Verify that the pin is configured as an output. If configured as an input, it will be powered by a weak pull up inside the MCU rather than from the much stronger output drive.

\$\endgroup\$
1
  • \$\begingroup\$ As stupid as I feel now, this was the issue. I'd written a quick test loop and was forgetting to assign the direction. \$\endgroup\$ Oct 22 '13 at 4:32
1
\$\begingroup\$

Essential for the brightness of the LED is the current through it. Different types of LEDs have different nominal currents. Typical is 20 mA or 2 mA for low current types. The ATmega can typically drive 40 mA per output pin. Assuming your supply (the programmer in your case) can give you enough current, you have to correctly set up the port pin in your source code by setting the appropriate port direction register and the port itself and you have to calculate the value of the series resistor.

This resistance depends on the output voltage of your microcontroller, the needed current through your LED and the voltage over your LED which basically depends on its color. For example a standard red LED has a little less than 2V and 20mA. With 5V from the controller you have 3V over your resistor, so to get 20mA through resistor and LED you need 150 Ohm. If you don't have a datasheet for your LED you find values for different colors on the web or even a series resistance calculator.

\$\endgroup\$
0
\$\begingroup\$

The voltage on an Arduino usually defaults to 5 volts. The programmer might only be using 3.3 volts.

This would likely result in more than a 1/3 loss in brightness due to the nonlinear nature of the LED's forward voltage drop.

In any case, get out a voltmeter and check the voltage between VCC (or VDD) and GND. Also, you can check the voltage across the LED's resistor, then use I=V/R to find the LED current.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.