# Arduino Mega 2560 LED is dim when powered from digital output

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?

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

The `pinMode()` arguments are backwards. As it is the LED is powered through the input pullup resistor, which is about 20-50kohm.
{"ft_lang_label":"__label__en","ft_lang_prob":0.9016814,"math_prob":0.8629592,"size":840,"snap":"2021-31-2021-39","text_gpt3_token_len":239,"char_repetition_ratio":0.10645933,"word_repetition_ratio":0.0,"special_character_ratio":0.28452381,"punctuation_ratio":0.13157895,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9796589,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-21T01:33:00Z\",\"WARC-Record-ID\":\"<urn:uuid:ef9c667f-d7e0-42f9-8a2c-4298972a7dd5>\",\"Content-Length\":\"166528\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:7dbe37a8-e107-4ad9-ad08-2509c4437c35>\",\"WARC-Concurrent-To\":\"<urn:uuid:9288c96c-cfb0-4b60-b125-169af8f11b87>\",\"WARC-IP-Address\":\"151.101.1.69\",\"WARC-Target-URI\":\"https://arduino.stackexchange.com/questions/46021/arduino-mega-2560-led-is-dim-when-powered-from-digital-output\",\"WARC-Payload-Digest\":\"sha1:DUARUT2533E5WGKSALAV43Z4UEOXX7IJ\",\"WARC-Block-Digest\":\"sha1:SZ5DIGNMUSSQP7H6A74W6HLTMPXEACNH\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780057131.88_warc_CC-MAIN-20210921011047-20210921041047-00174.warc.gz\"}"}