LED intensity on digital pins [duplicate]












2















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.










share|improve this 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
















2















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.










share|improve this 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














2












2








2








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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










1 Answer
1






active

oldest

votes


















6














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).






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    6














    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).






    share|improve this answer




























      6














      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).






      share|improve this answer


























        6












        6








        6






        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).






        share|improve this answer














        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).







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Dec 1 '18 at 11:32

























        answered Dec 1 '18 at 11:27









        Edgar Bonet

        24k22344




        24k22344















            Popular posts from this blog

            Wiesbaden

            Marschland

            Dieringhausen