0

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() {
pinMode(OUTPUT,red); 
}
void loop() { 
digitalWrite(red,HIGH);
}

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?

asked Oct 29, 2017 at 14:47
1
  • 1
    It's pinMode(red, OUTPUT) Commented Oct 29, 2017 at 15:21

1 Answer 1

1

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

answered Oct 29, 2017 at 15:00
1
  • 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. Commented Oct 29, 2017 at 15:06

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.