Go Down

Topic: Internal pull-up resistors (Read 695 times) previous topic - next topic

1Bryan

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

justjed

#1
Sep 10, 2012, 12:49 am Last Edit: Sep 10, 2012, 12:51 am by justjed Reason: 1
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.
... it is poor civic hygiene to install technologies that could someday
facilitate a police state. -- Bruce Schneier

retrolefty

#2
Sep 10, 2012, 01:13 am Last Edit: Sep 10, 2012, 01:17 am by retrolefty Reason: 1

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

Go Up