Pages: [1]   Go Down
Author Topic: Internal pull-up resistors  (Read 665 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi when I code digitalWrite(inputPin, HIGH) is this just assigning a value of 1 to my inputPin or is it actually applying a voltage near 5V to that pin? 

Does anyone know where I can find a diagram of this internal resistor?

Thanks
Logged

CO, USA
Offline Offline
God Member
*****
Karma: 5
Posts: 711
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, according to the reference material:
Quote
If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.

If the pin is configured as an INPUT, writing a HIGH value with digitalWrite() will enable an internal 20K pullup resistor (see the tutorial on digital pins).

I haven't dug through it, but I assume there's specific documentation in the Atmega328 datasheet. If you just want a simplified equivalent circuit drawing, check Grumpy Mike's tutorial.

The value of '1' is meaningless. Maybe you're assuming the 'TRUE' = '1'? But a pin HIGH or LOW is neither TRUE nor FALSE, without any context.

ETA: Perhaps this thread will help you.
« Last Edit: September 09, 2012, 05:51:26 pm by justjed » Logged

... it is poor civic hygiene to install technologies that could someday
facilitate a police state. -- Bruce Schneier

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi when I code digitalWrite(inputPin, HIGH) is this just assigning a value of 1 to my inputPin or is it actually applying a voltage near 5V to that pin?  

Does anyone know where I can find a diagram of this internal resistor?

Thanks

The statement digitalWrite(inputPin, HIGH) without context of what the last mode control was (or if the pin is still at the reset/power-up default input mode). The variable inputPin is just a number and by itself doesn't set the pin mode to either input or output mode, it's just used to address the desired pin.

Anyway, if the pin is in fact in input mode, then the digitalWrite(inputPin, HIGH) statement will enable the internal pull-up resistor so the pin will measure a +5vdc at the pin connection, however it does not have the output current capacity of a output pin, just a 40k or so series resistor wired to +5vdc. If the pins mode was set to output mode prior, then the statement digitalWrite(inputPin, HIGH) will set the output to +5vdc and be able to source current up to the rated maximum value.

Figure 14.2 of the AVR mega328 datasheet (version Rev. 8271D–AVR–05/11) shows the I/O pin configuration and an explanation of how the I/O pins work.

Does that help?
Lefty
« Last Edit: September 09, 2012, 06:17:20 pm by retrolefty » Logged

Pages: [1]   Go Up
Jump to: