LED intensity on digital pins [duplicate]
This question already has an answer here:
Arduino Mega 2560 LED is dim when powered from digital output
1 answer
I am using an Arduino UNO.
On any digital/analog pin, if an LED (with resistor) is connected and we use digitalWrite(pin,HIGH) the LED lights up rather dimly.
On the other hand, if we use pinMode(pin,OUTPUT) and then use digitalWrite, the LED lights up to maximum intensity.
I checked that in both cases, the voltage on the pin is 5V. Any explanation for this ? Thanks.
arduino-uno led
marked as duplicate by Juraj, sempaiscuba, Greenonline, Gerben, VE7JRO Dec 1 '18 at 15:02
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Arduino Mega 2560 LED is dim when powered from digital output
1 answer
I am using an Arduino UNO.
On any digital/analog pin, if an LED (with resistor) is connected and we use digitalWrite(pin,HIGH) the LED lights up rather dimly.
On the other hand, if we use pinMode(pin,OUTPUT) and then use digitalWrite, the LED lights up to maximum intensity.
I checked that in both cases, the voltage on the pin is 5V. Any explanation for this ? Thanks.
arduino-uno led
marked as duplicate by Juraj, sempaiscuba, Greenonline, Gerben, VE7JRO Dec 1 '18 at 15:02
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
This is not a duplicate question. I am specifically asking the effect of declaring a pin as OUTPUT versus direct use of digitalWrite on the pin.
– Frost
Dec 1 '18 at 12:02
add a comment |
This question already has an answer here:
Arduino Mega 2560 LED is dim when powered from digital output
1 answer
I am using an Arduino UNO.
On any digital/analog pin, if an LED (with resistor) is connected and we use digitalWrite(pin,HIGH) the LED lights up rather dimly.
On the other hand, if we use pinMode(pin,OUTPUT) and then use digitalWrite, the LED lights up to maximum intensity.
I checked that in both cases, the voltage on the pin is 5V. Any explanation for this ? Thanks.
arduino-uno led
This question already has an answer here:
Arduino Mega 2560 LED is dim when powered from digital output
1 answer
I am using an Arduino UNO.
On any digital/analog pin, if an LED (with resistor) is connected and we use digitalWrite(pin,HIGH) the LED lights up rather dimly.
On the other hand, if we use pinMode(pin,OUTPUT) and then use digitalWrite, the LED lights up to maximum intensity.
I checked that in both cases, the voltage on the pin is 5V. Any explanation for this ? Thanks.
This question already has an answer here:
Arduino Mega 2560 LED is dim when powered from digital output
1 answer
arduino-uno led
arduino-uno led
edited Dec 1 '18 at 12:02
asked Dec 1 '18 at 11:20
Frost
133
133
marked as duplicate by Juraj, sempaiscuba, Greenonline, Gerben, VE7JRO Dec 1 '18 at 15:02
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Juraj, sempaiscuba, Greenonline, Gerben, VE7JRO Dec 1 '18 at 15:02
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
This is not a duplicate question. I am specifically asking the effect of declaring a pin as OUTPUT versus direct use of digitalWrite on the pin.
– Frost
Dec 1 '18 at 12:02
add a comment |
This is not a duplicate question. I am specifically asking the effect of declaring a pin as OUTPUT versus direct use of digitalWrite on the pin.
– Frost
Dec 1 '18 at 12:02
This is not a duplicate question. I am specifically asking the effect of declaring a pin as OUTPUT versus direct use of digitalWrite on the pin.
– Frost
Dec 1 '18 at 12:02
This is not a duplicate question. I am specifically asking the effect of declaring a pin as OUTPUT versus direct use of digitalWrite on the pin.
– Frost
Dec 1 '18 at 12:02
add a comment |
1 Answer
1
active
oldest
votes
This is due to a specific feature of the AVR microcontrollers, where the
same register (PORTB
, PORTC
or PORTD
) is used for controlling both
the output value of the pin and its optional internal pullup resistor.
The command digitalWrite(pin,HIGH)
sets to 1 the bit of this register
corresponding to the selected pin.
If the pin is set to
INPUT
(which is the default), the effect of
digitalWrite(pin,HIGH)
is to turn on the internal pullup.If the pin is set to
OUTPUT
, the same command sets the output to
HIGH
.
The internal pullup is about 30 kΩ, which lets flow a very small
current through the LED. You may notice that the voltage at the pin is
5 V if nothing is connected to it, but significantly less when the
LED is connected. Notice also that the preferred way of enabling the
pullup is pinMode(pin,INPUT_PULLUP)
.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is due to a specific feature of the AVR microcontrollers, where the
same register (PORTB
, PORTC
or PORTD
) is used for controlling both
the output value of the pin and its optional internal pullup resistor.
The command digitalWrite(pin,HIGH)
sets to 1 the bit of this register
corresponding to the selected pin.
If the pin is set to
INPUT
(which is the default), the effect of
digitalWrite(pin,HIGH)
is to turn on the internal pullup.If the pin is set to
OUTPUT
, the same command sets the output to
HIGH
.
The internal pullup is about 30 kΩ, which lets flow a very small
current through the LED. You may notice that the voltage at the pin is
5 V if nothing is connected to it, but significantly less when the
LED is connected. Notice also that the preferred way of enabling the
pullup is pinMode(pin,INPUT_PULLUP)
.
add a comment |
This is due to a specific feature of the AVR microcontrollers, where the
same register (PORTB
, PORTC
or PORTD
) is used for controlling both
the output value of the pin and its optional internal pullup resistor.
The command digitalWrite(pin,HIGH)
sets to 1 the bit of this register
corresponding to the selected pin.
If the pin is set to
INPUT
(which is the default), the effect of
digitalWrite(pin,HIGH)
is to turn on the internal pullup.If the pin is set to
OUTPUT
, the same command sets the output to
HIGH
.
The internal pullup is about 30 kΩ, which lets flow a very small
current through the LED. You may notice that the voltage at the pin is
5 V if nothing is connected to it, but significantly less when the
LED is connected. Notice also that the preferred way of enabling the
pullup is pinMode(pin,INPUT_PULLUP)
.
add a comment |
This is due to a specific feature of the AVR microcontrollers, where the
same register (PORTB
, PORTC
or PORTD
) is used for controlling both
the output value of the pin and its optional internal pullup resistor.
The command digitalWrite(pin,HIGH)
sets to 1 the bit of this register
corresponding to the selected pin.
If the pin is set to
INPUT
(which is the default), the effect of
digitalWrite(pin,HIGH)
is to turn on the internal pullup.If the pin is set to
OUTPUT
, the same command sets the output to
HIGH
.
The internal pullup is about 30 kΩ, which lets flow a very small
current through the LED. You may notice that the voltage at the pin is
5 V if nothing is connected to it, but significantly less when the
LED is connected. Notice also that the preferred way of enabling the
pullup is pinMode(pin,INPUT_PULLUP)
.
This is due to a specific feature of the AVR microcontrollers, where the
same register (PORTB
, PORTC
or PORTD
) is used for controlling both
the output value of the pin and its optional internal pullup resistor.
The command digitalWrite(pin,HIGH)
sets to 1 the bit of this register
corresponding to the selected pin.
If the pin is set to
INPUT
(which is the default), the effect of
digitalWrite(pin,HIGH)
is to turn on the internal pullup.If the pin is set to
OUTPUT
, the same command sets the output to
HIGH
.
The internal pullup is about 30 kΩ, which lets flow a very small
current through the LED. You may notice that the voltage at the pin is
5 V if nothing is connected to it, but significantly less when the
LED is connected. Notice also that the preferred way of enabling the
pullup is pinMode(pin,INPUT_PULLUP)
.
edited Dec 1 '18 at 11:32
answered Dec 1 '18 at 11:27
Edgar Bonet
24k22344
24k22344
add a comment |
add a comment |
This is not a duplicate question. I am specifically asking the effect of declaring a pin as OUTPUT versus direct use of digitalWrite on the pin.
– Frost
Dec 1 '18 at 12:02