My circuit is a simple one, I am using an arduino atmega 2560. One 5mm red LED connected in series with a 150 ohm resistor. If I didn't make some kind of goof, a red LED has a voltage drop of 2 volts and operates at 20 ma. So my calculations were, 5-2=3volts. 3V/150=20 mA. So I put a 150 ohm resistor. My code to control it is the following:

int red = 48;

void setup() {

void loop() {    

When I run the code the red LED is dimly lit, when connected to the 5V on the board it lights brightly. When I measured the voltage between pin48 and ground I got 1.7 volts. When connected directly to the 5V and GND the voltage between them is 4.95V. Measuring a pin with nothing connected set at HIGH results in a 4.99V reading. Is my board malfunctioning or have I missed something?

  • 1
    It's pinMode(red, OUTPUT)
    – user31481
    Oct 29, 2017 at 15:21

1 Answer 1


The pinMode() arguments are backwards. As it is the LED is powered through the input pullup resistor, which is about 20-50kohm.

  • You sir deserve a pizza, thank you so much! I noticed it now, what a dumb mistake :D Well I fixed it now and it works. Cheers again for the help.
    – Entity5
    Oct 29, 2017 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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