# Newbie question : using  10K resistors in inp

I’m a completely newbie, still waiting for by arduino to arrive, so have been reading the arduino notebook and booklet to get to grips with a few ideas.

I’m a programmer by trade, and electronics isn’t my strong point (not yet anway!) :

I noticed that in the schematics the input from say a switch or a variable resistor isn’t directly wired like
5V ----> variable resistor ----> Pin In
or a switch like
5V ----> switch ----> Pin In

The diagrams show a resistor like so :

and :

Why is this?

I know I need a lesson in Electronics 101 !!! :

Excellent site thanks. I’ve started looking through her tutorials.

So I’m guessing that while the switch is open the pin in is held low at 0V.

Without the resistor, the pin is considered to be floating and would be susceptible to problems with electrical noise. Right?

So I’m guessing that while the switch is open the pin in is held low at 0V.

Without the resistor, the pin is considered to be floating and would be susceptible to problems with electrical noise. Right?

You’ve got it.

A couple of other notes: more often than not, lines are pulled “up” to 5V rather than “down” to ground. This has the effect of making your switch logic inverted (i.e. pin is low/0 when button is pressed, high/1 otherwise).

The Arduino’s ATmega has some built-in pullup resistors that can be enabled, to save you the trouble of adding them to your circuit. I don’t recall for sure off the top of my head how to enable them - IIRC, you set it as an input, then write a 1 to it as if it were an output.

-j

[The Arduino’s ATmega has some built-in pullup resistors that can be enabled, to save you the trouble of adding them to your circuit. I don’t recall for sure off the top of my head how to enable them - IIRC, you set it as an input, then write a 1 to it as if it were an output.

Wow! I had no idea there were internal pull-ups. I did a site search, and I couldn’t find it documented anywhere. Anybody have a reference for that? If not, someone should add it to the documentation.

ATmega168 datasheet (375 pages of ATmega information overload) page 3 says

Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The
Port B output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up
resistors are activated.

Ports C and D (i.e. all the general purpose I/O pins) are likewise endowed.

-j