Tutorial.DigitalPins History

Hide minor edits - Show changes to markup

February 03, 2014, at 03:30 PM by Scott Fitzgerald -
Added lines 19-20:

The value of this pullup depends on the microcontroller used. On most AVR-based boards, the value is guaranteed to be between 20kΩ and 50kΩ. On the Arduino Due, it is between 50kΩ and 150kΩ. For the exact value, consult the datasheet of the microcontroller on your board.

May 07, 2012, at 05:45 PM by Tom Igoe -
Changed lines 11-12 from:

Pullup Resistors with pins configured as INPUT

to:

Pullup Resistors with pins configured as INPUT

May 07, 2012, at 05:45 PM by Tom Igoe -
Changed lines 7-8 from:

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode() when you're using them as inputs. Pins configured this way are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading an LED as a photodiode, or reading an analog sensor with a scheme such as RCTime.

to:

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode() when you're using them as inputs. Pins configured this way are said to be in a high-impedance state. Input pins make extremely small demands on the circuit that they are sampling, equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading an LED as a photodiode, or reading an analog sensor with a scheme such as RCTime.

Changed lines 13-14 from:

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or a pulldown resistor (resistor to ground) on the input, with 10K being a common value.

to:

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or a pulldown resistor (resistor to ground) on the input. A 10K resistor is a good value for a pullup or pulldown resistor.

Changed lines 21-24 from:

Note that the pullup resistors provide enough current to dimly light an LED connected to a pin that has been configured as an input. If LEDs in a project seem to be working, but very dimly, this is likely what is going on.

Note also that the pullup resistors are controlled by the same registers (internal chip memory locations) that control whether a pin is HIGH or LOW. Consequently, a pin that is configured to have pullup resistors turned on when the pin is an INPUT, will have the pin configured as HIGH if the pin is then switched to an OUTPUT with pinMode(). This works in the other direction as well, and an output pin that is left in a HIGH state will have the pullup resistors set if switched to an input with pinMode().

to:

The pullup resistors provide enough current to dimly light an LED connected to a pin that has been configured as an input. If LEDs in a project seem to be working, but very dimly, this is likely what is going on.

The pullup resistors are controlled by the same registers (internal chip memory locations) that control whether a pin is HIGH or LOW. Consequently, a pin that is configured to have pullup resistors turned on when the pin is an INPUT, will have the pin configured as HIGH if the pin is then switched to an OUTPUT with pinMode(). This works in the other direction as well, and an output pin that is left in a HIGH state will have the pullup resistors set if switched to an input with pinMode().

May 07, 2012, at 05:40 PM by Tom Igoe -
Changed lines 7-8 from:

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading an LED as a photodiode, or reading an analog sensor with a scheme such as RCTime.

to:

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode() when you're using them as inputs. Pins configured this way are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading an LED as a photodiode, or reading an analog sensor with a scheme such as RCTime.

March 28, 2012, at 03:01 PM by Scott Fitzgerald -
Changed lines 17-18 from:

There are 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed by setting the pinMode() as INPUT_PULLUP.

to:

There are 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed by setting the pinMode() as INPUT_PULLUP. This effectively inverts the behavior of the INPUT mode, where HIGH means the sensor is off, and LOW means the sensor is on.

March 28, 2012, at 02:57 PM by Scott Fitzgerald -
Changed lines 11-12 from:

Pullup Resistors

to:

Pullup Resistors with pins configured as INPUT

Changed lines 15-16 from:

There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed by setting the pinMode() as INPUT_PULLUP.

to:

Properties of Pins Configured as INPUT_PULLUP

There are 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed by setting the pinMode() as INPUT_PULLUP.

When connecting a sensor to a pin configured with INPUT_PULLUP, the other end should be connected to ground. In the case of a simple switch, this causes the pin to read HIGH when the switch is open, and LOW when the switch is pressed.

Note that the pullup resistors provide enough current to dimly light an LED connected to a pin that has been configured as an input. If LEDs in a project seem to be working, but very dimly, this is likely what is going on.

Note also that the pullup resistors are controlled by the same registers (internal chip memory locations) that control whether a pin is HIGH or LOW. Consequently, a pin that is configured to have pullup resistors turned on when the pin is an INPUT, will have the pin configured as HIGH if the pin is then switched to an OUTPUT with pinMode(). This works in the other direction as well, and an output pin that is left in a HIGH state will have the pullup resistors set if switched to an input with pinMode().

Changed lines 32-37 from:

Note that the pullup resistors provide enough current to dimly light an LED connected to a pin that has been configured as an input. If LED's in a project seem to be working, but very dimly, this is likely what is going on, and the programmer has forgotten to use pinMode() to set the pins to outputs.

Note also that the pullup resistors are controlled by the same registers (internal chip memory locations) that control whether a pin is HIGH or LOW. Consequently, a pin that is configured to have pullup resistors turned on when the pin is an INPUT, will have the pin configured as HIGH if the pin is then swtiched to an OUTPUT with pinMode(). This works in the other direction as well, and an output pin that is left in a HIGH state will have the pullup resistors set if switched to an input with pinMode().

NOTE: Digital pin 13 is harder to use as a digital input than the other digital pins because it has an LED and resistor attached to it that's soldered to the board on most boards. If you enable its internal 20k pull-up resistor, it will hang at around 1.7 V instead of the expected 5V because the onboard LED and series resistor pull the voltage level down, meaning it always returns LOW. If you must use pin 13 as a digital input, use an external pull down resistor.

to:

NOTE: Digital pin 13 is harder to use as a digital input than the other digital pins because it has an LED and resistor attached to it that's soldered to the board on most boards. If you enable its internal 20k pull-up resistor, it will hang at around 1.7V instead of the expected 5V because the onboard LED and series resistor pull the voltage level down, meaning it always returns LOW. If you must use pin 13 as a digital input, set its pinMode() to INPUT and use an external pull down resistor.

March 15, 2012, at 01:53 AM by Scott Fitzgerald - added initial input_pullup notes
Changed lines 9-10 from:

This also means however, that input pins with nothing connected to them, or with wires connected to them that are not connected to other circuits, will report seemingly random changes in pin state, picking up electrical noise from the environment, or capacitively coupling the state of a nearby pin.

to:

This also means however, that pins configured as pinMode(pin, INPUT) with nothing connected to them, or with wires connected to them that are not connected to other circuits, will report seemingly random changes in pin state, picking up electrical noise from the environment, or capacitively coupling the state of a nearby pin.

Changed lines 15-16 from:

There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed in the following manner.

to:

There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed by setting the pinMode() as INPUT_PULLUP.

Prior to Arduino 1.0.1, it was possible to configure the internal pull-ups in the following manner:

Changed lines 26-27 from:

Note also that the pullup resistors are controlled by the same registers (internal chip memory locations) that control whether a pin is HIGH or LOW. Consequently a pin that is configured to have pullup resistors turned on when the pin is an INPUT, will have the pin configured as HIGH if the pin is then swtiched to an OUTPUT with pinMode(). This works in the other direction as well, and an output pin that is left in a HIGH state will have the pullup resistors set if switched to an input with pinMode().

to:

Note also that the pullup resistors are controlled by the same registers (internal chip memory locations) that control whether a pin is HIGH or LOW. Consequently, a pin that is configured to have pullup resistors turned on when the pin is an INPUT, will have the pin configured as HIGH if the pin is then swtiched to an OUTPUT with pinMode(). This works in the other direction as well, and an output pin that is left in a HIGH state will have the pullup resistors set if switched to an input with pinMode().

Changed line 41 from:
to:
March 15, 2012, at 01:53 AM by Scott Fitzgerald -
March 09, 2010, at 04:41 AM by Tom Igoe -
Changed lines 26-28 from:

NOTE: Digital pin 13 is harder to use as a digital input because has an LED and resistor attached to it that's soldered to the board on most boards. If you enable its internal 20k pull-up resistor, it will hang at around 1.7 V instead of the expected 5V because the onboard LED and series resistor pull the voltage level down, meaning it always returns LOW. If you must use pin 13 as a digital input, use an external pull down resistor.

to:

NOTE: Digital pin 13 is harder to use as a digital input than the other digital pins because it has an LED and resistor attached to it that's soldered to the board on most boards. If you enable its internal 20k pull-up resistor, it will hang at around 1.7 V instead of the expected 5V because the onboard LED and series resistor pull the voltage level down, meaning it always returns LOW. If you must use pin 13 as a digital input, use an external pull down resistor.

Changed line 39 from:
to:
March 09, 2010, at 04:35 AM by Tom Igoe -
Changed lines 26-28 from:

NOTE: Digital pin 13 has an LED and resistor attached to it that's soldered to the board on most boards, so it's not advised to use it as a digital input. If you enable its internal 20k pull-up resistor, it will hang at around 1.7 V instead of the expected 5V because the onboard LED and series resistor pull the voltage level down, meaning it always returns LOW.

to:

NOTE: Digital pin 13 is harder to use as a digital input because has an LED and resistor attached to it that's soldered to the board on most boards. If you enable its internal 20k pull-up resistor, it will hang at around 1.7 V instead of the expected 5V because the onboard LED and series resistor pull the voltage level down, meaning it always returns LOW. If you must use pin 13 as a digital input, use an external pull down resistor.

March 08, 2010, at 04:48 AM by Tom Igoe -
Changed lines 26-28 from:
to:

NOTE: Digital pin 13 has an LED and resistor attached to it that's soldered to the board on most boards, so it's not advised to use it as a digital input. If you enable its internal 20k pull-up resistor, it will hang at around 1.7 V instead of the expected 5V because the onboard LED and series resistor pull the voltage level down, meaning it always returns LOW.

February 06, 2010, at 09:30 AM by David A. Mellis -
Deleted line 35:
February 06, 2010, at 09:30 AM by David A. Mellis -
Changed lines 5-25 from:

Understanding PORT registers

The best way to really understand the nature of Atmega microcontroller pins used by the Arduino, is to understand the underlying port registers in the Atmega chip. These are the memory locations that control the electrical function of the pins. More details on this may be found in the Port Manipulation reference page.

There are three port registers that control every pin on the Atmega168/328 chip. The lower case x's in the names are place holders for individual port letter designations. This will be more clear if you glance at the Port Manipulation page.

Port Registers That Control Atmega (Arduino) Pins

    DDRx - The Port Data Direction Register - read/write
    PORTx - The Port Data Register - read/write
    PINx - The Port Input Pins Register - read only 

The setting of the DDR register controls whether the pin is an an input or output. DDR registers may be either read or written.

The setting of the PORT register controls whether the pin is HIGH or LOW, when the pin is in an OUTPUT state (DDR register set). When the pin is configured to an INPUT state (DDR register reset), the PORT register controls whether the pin has its pullup resistor set. PORT registers may be either read or written.

As you can see then, the DDR and PORT registers interact in controlling the pin states, so understanding the state of the pin requires understanding both registers.

The PIN register is a read-only register that indicates the electrical condition of the pin. In other words, if the voltage level of the pin is above about 2.5 volts (or half the supply voltage if VCC is less than 5 volts) this register will read as a 1, if not it will read as a 0. The PIN register cannot be written, since its value depends on the external voltage level of the pin.

Register Settings Chart

to:

Properties of Pins Configured as INPUT

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading an LED as a photodiode, or reading an analog sensor with a scheme such as RCTime.

This also means however, that input pins with nothing connected to them, or with wires connected to them that are not connected to other circuits, will report seemingly random changes in pin state, picking up electrical noise from the environment, or capacitively coupling the state of a nearby pin.

Pullup Resistors

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or a pulldown resistor (resistor to ground) on the input, with 10K being a common value.

There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed in the following manner.

Changed lines 18-51 from:
   I/O condition          pin state         register states 

                                            DDRx  == 0
                         PULLUPS ON         PORTx == 1

PIN SET AS INPUT

                                            DDRx  == 0
                        PULLUPS OFF         PORTx == 0

                                            DDRx  == 1
                           PIN HIGH         PORTx == 1

PIN SET AS OUTPUT

                                            DDRx  == 1
                            PIN LOW         PORTx == 0

Arduino function low level result pin condition


pinMode() sets the DDR register INPUT == 0

                                                   OUTPUT == 1

                                           INPUT STATE (DDRx == 0)    |    OUTPUT STATE (DDRx == 1)

digitalWrite() sets PORT register LOW (PULLUPS OFF) == 0 LOW == 0

                                           HIGH (PULLUPS ON) ==  1         HIGH == 1

                        Voltage at Pin              Voltage < 2.5     |    Voltage > 2.5

digitalRead() reads the PIN register returns 0 returns 1

to:

pinMode(pin, INPUT); // set pin to input digitalWrite(pin, HIGH); // turn on pullup resistors

Deleted lines 21-37:

Properties of Pins Configured as INPUT

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading an LED as a photodiode, or reading an analog sensor with a scheme such as RCTime.

This also means however, that input pins with nothing connected to them, or with wires connected to them that are not connected to other circuits, will report seemingly random changes in pin state, picking up electrical noise from the environment, or capacitively coupling the state of a nearby pin.

Pullup Resistors

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or a pulldown resistor (resistor to ground) on the input, with 10K being a common value.

There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed in the following manner.

pinMode(pin, INPUT);           // set pin to input
digitalWrite(pin, HIGH);       // turn on pullup resistors

January 20, 2010, at 02:18 PM by Paul Badger -
Changed line 54 from:

digitalWrite() sets PORT register LOW (PULLUPS OFF) == 0 LOW == 0

to:

digitalWrite() sets PORT register LOW (PULLUPS OFF) == 0 LOW == 0

January 20, 2010, at 02:17 PM by Paul Badger -
Changed line 60 from:

digitalRead() reads the PIN register returns 0 returns 1

to:

digitalRead() reads the PIN register returns 0 returns 1

January 20, 2010, at 02:17 PM by Paul Badger -
Changed lines 52-53 from:
                                      INPUT STATE (DDRx == 0)    |    OUTPUT STATE (DDRx == 1)
to:
                                           INPUT STATE (DDRx == 0)    |    OUTPUT STATE (DDRx == 1)
Changed lines 58-59 from:
                       Voltage at Pin        Voltage < 2.5     |    Voltage > 2.5
to:
                        Voltage at Pin              Voltage < 2.5     |    Voltage > 2.5
January 20, 2010, at 02:15 PM by Paul Badger -
Changed lines 58-59 from:
                         Voltage at Pin        Voltage < 2.5      |      Voltage > 2.5
to:
                       Voltage at Pin        Voltage < 2.5     |    Voltage > 2.5
January 20, 2010, at 02:15 PM by Paul Badger -
Changed lines 52-53 from:
                                         INPUT STATE (DDRx == 0)    |    OUTPUT STATE (DDRx == 1)
to:
                                      INPUT STATE (DDRx == 0)    |    OUTPUT STATE (DDRx == 1)
January 20, 2010, at 02:14 PM by Paul Badger -
Changed lines 52-53 from:
                                INPUT STATE (DDRx == 0)    |      OUTPUT STATE (DDRx == 1)
to:
                                         INPUT STATE (DDRx == 0)    |    OUTPUT STATE (DDRx == 1)
January 20, 2010, at 02:13 PM by Paul Badger -
Changed lines 52-57 from:
                                     INPUT STATE (DDRx == 0)    |      OUTPUT STATE (DDRx == 1)

digitalWrite() sets PORT register LOW (PULLUPS OFF) == 0 LOW == 0

                                           HIGH (PULLUPS ON) ==  1             HIGH == 1

to:
                                INPUT STATE (DDRx == 0)    |      OUTPUT STATE (DDRx == 1)

digitalWrite() sets PORT register LOW (PULLUPS OFF) == 0 LOW == 0

                                           HIGH (PULLUPS ON) ==  1         HIGH == 1

January 20, 2010, at 02:12 PM by Paul Badger -
January 20, 2010, at 02:10 PM by Paul Badger -
Changed lines 52-53 from:
                                  INPUT STATE (DDRx == 0)       |       OUTPUT STATE (DDRx == 1)
to:
                                     INPUT STATE (DDRx == 0)    |      OUTPUT STATE (DDRx == 1)
January 20, 2010, at 02:09 PM by Paul Badger -
Changed line 27 from:
   I/O condition          pin state       register states 
to:
   I/O condition          pin state         register states 
Changed lines 29-31 from:
                                        DDRx  == 0
                         PULLUPS ON     PORTx == 1
to:
                                            DDRx  == 0
                         PULLUPS ON         PORTx == 1
Changed lines 33-39 from:
                                        DDRx  == 0
                        PULLUPS OFF     PORTx == 0

                                         DDRx  == 1
                           PIN HIGH      PORTx == 1
to:
                                            DDRx  == 0
                        PULLUPS OFF         PORTx == 0

                                            DDRx  == 1
                           PIN HIGH         PORTx == 1
Changed lines 41-45 from:
                                         DDRx  == 1
                            PIN LOW      PORTx == 0

to:
                                            DDRx  == 1
                            PIN LOW         PORTx == 0

January 20, 2010, at 02:08 PM by Paul Badger -
Changed line 25 from:

Register Settings Diagram

to:

Register Settings Chart

Deleted line 26:
January 20, 2010, at 02:08 PM by Paul Badger -
Changed line 47 from:

Arduino function low level result pin condition

to:

Arduino function low level result pin condition

Changed line 49 from:

pinMode() sets the DDR register INPUT == 0

to:

pinMode() sets the DDR register INPUT == 0

Changed lines 55-61 from:

digitalWrite() sets PORT register LOW (PULLUPS OFF) == 0 LOW == 0

                                       HIGH (PULLUPS ON) ==  1             HIGH == 1

                      Voltage at Pin        Voltage < 2.5      |      Voltage > 2.5

digitalRead() reads the PIN register returns 0 returns 1

to:

digitalWrite() sets PORT register LOW (PULLUPS OFF) == 0 LOW == 0

                                           HIGH (PULLUPS ON) ==  1             HIGH == 1

                         Voltage at Pin        Voltage < 2.5      |      Voltage > 2.5

digitalRead() reads the PIN register returns 0 returns 1

January 20, 2010, at 02:05 PM by Paul Badger -
Changed lines 53-54 from:
                                             INPUT STATE (DDRx == 0)       |       OUTPUT STATE (DDRx == 1)
to:
                                  INPUT STATE (DDRx == 0)       |       OUTPUT STATE (DDRx == 1)
January 20, 2010, at 02:04 PM by Paul Badger -
Changed line 50 from:
                                               OUTPUT == 1
to:
                                                   OUTPUT == 1
Changed lines 53-54 from:
                                             INPUT STATE       |       OUTPUT STATE
to:
                                             INPUT STATE (DDRx == 0)       |       OUTPUT STATE (DDRx == 1)
January 20, 2010, at 02:02 PM by Paul Badger -
Changed lines 56-58 from:
                                     HIGH (PULLUPS ON) ==  1             HIGH == 1

to:
                                       HIGH (PULLUPS ON) ==  1             HIGH == 1

January 20, 2010, at 02:00 PM by Paul Badger -
Changed lines 23-24 from:

The PIN register is a read only register that indicates the electrical condition of the pin. In other words, if the voltage level of the pin is above about 2.5 volts (or half the supply voltage if VCC is less than 5 volts) this register will read as a 1, if not it will read as a 0. The PIN register cannot be written, since its value depends on the external voltage level of the pin.

to:

The PIN register is a read-only register that indicates the electrical condition of the pin. In other words, if the voltage level of the pin is above about 2.5 volts (or half the supply voltage if VCC is less than 5 volts) this register will read as a 1, if not it will read as a 0. The PIN register cannot be written, since its value depends on the external voltage level of the pin.

January 20, 2010, at 01:59 PM by Paul Badger -
Changed line 49 from:

pinMode() sets the DDR register INPUT == 0

to:

pinMode() sets the DDR register INPUT == 0

Changed line 55 from:

digitalWrite() sets PORT register LOW (PULLUPS OFF) == 0 LOW == 0

to:

digitalWrite() sets PORT register LOW (PULLUPS OFF) == 0 LOW == 0

January 20, 2010, at 01:58 PM by Paul Badger -
Changed lines 28-32 from:
   I/O condition      pin state     register states 

                                     DDRx  == 0
                      PULLUPS ON     PORTx == 1
to:
   I/O condition          pin state       register states 

                                        DDRx  == 0
                         PULLUPS ON     PORTx == 1
Changed lines 34-40 from:
                                     DDRx  == 0
                     PULLUPS OFF     PORTx == 0

                                     DDRx  == 1
                       PIN HIGH      PORTx == 1
to:
                                        DDRx  == 0
                        PULLUPS OFF     PORTx == 0

                                         DDRx  == 1
                           PIN HIGH      PORTx == 1
Changed lines 42-46 from:
                                     DDRx  == 1
                        PIN LOW      PORTx == 0

to:
                                         DDRx  == 1
                            PIN LOW      PORTx == 0

Changed line 48 from:

to:

January 20, 2010, at 01:55 PM by Paul Badger -
Changed line 29 from:
to:

Changed lines 47-48 from:

Arduino function low level result pin condition


to:

Arduino function low level result pin condition


January 20, 2010, at 01:53 PM by Paul Badger -
Changed lines 47-48 from:
to:

Arduino function low level result pin condition


January 20, 2010, at 01:49 PM by Paul Badger -
Added lines 27-29:
   I/O condition      pin state     register states 
January 20, 2010, at 01:46 PM by Paul Badger -
Changed lines 23-24 from:

The PIN register is a read only register that indicates the electrical condition of the pin. In other words, if the voltage level of the pin is above about 2.5 volts this register will read as a 1, if not it will read as a 0. The PIN register cannot be written, since its value depends on the external voltage level of the pin.

to:

The PIN register is a read only register that indicates the electrical condition of the pin. In other words, if the voltage level of the pin is above about 2.5 volts (or half the supply voltage if VCC is less than 5 volts) this register will read as a 1, if not it will read as a 0. The PIN register cannot be written, since its value depends on the external voltage level of the pin.

January 17, 2010, at 06:42 PM by Paul Badger -
Changed lines 23-24 from:

The PIN register is a read only register that indicates the electrical condition of the pin. In other words, if the voltage level of the pin is above about 2.5 volts this register will read as a 1, if not it will read as a 0.

to:

The PIN register is a read only register that indicates the electrical condition of the pin. In other words, if the voltage level of the pin is above about 2.5 volts this register will read as a 1, if not it will read as a 0. The PIN register cannot be written, since its value depends on the external voltage level of the pin.

January 17, 2010, at 06:33 PM by Paul Badger -
Changed lines 19-20 from:

The setting of the PORT register controls whether the pin is HIGH or LOW, when the pin is in an OUTPUT state. When the pin is configured to an INPUT state, the PORT register controls whether the pin has its pullup resistor set. PORT registers may be either read or written.

to:

The setting of the PORT register controls whether the pin is HIGH or LOW, when the pin is in an OUTPUT state (DDR register set). When the pin is configured to an INPUT state (DDR register reset), the PORT register controls whether the pin has its pullup resistor set. PORT registers may be either read or written.

January 17, 2010, at 06:28 PM by Paul Badger -
Changed lines 17-18 from:

The setting of the DDR register controls whether the pins is an an input or output. DDR registers may be either read or written.

to:

The setting of the DDR register controls whether the pin is an an input or output. DDR registers may be either read or written.

Added lines 21-22:

As you can see then, the DDR and PORT registers interact in controlling the pin states, so understanding the state of the pin requires understanding both registers.

January 17, 2010, at 06:22 PM by Paul Badger -
Added lines 42-43:
January 17, 2010, at 06:22 PM by Paul Badger -
Changed lines 42-43 from:

pinMode() sets the DDR register INPUT == 0

                                     OUTPUT == 1
to:

pinMode() sets the DDR register INPUT == 0

                                               OUTPUT == 1
January 17, 2010, at 06:19 PM by Paul Badger -
Changed lines 46-47 from:
                                             INPUT STATE        |      OUTPUT STATE
to:
                                             INPUT STATE       |       OUTPUT STATE
Changed lines 52-54 from:
                      Voltage at Pin        Voltage < 2.5       |          Voltage > 2.5

digitalRead() reads the PIN register returns 0 returns 1

to:
                      Voltage at Pin        Voltage < 2.5      |      Voltage > 2.5

digitalRead() reads the PIN register returns 0 returns 1

January 17, 2010, at 06:18 PM by Paul Badger -
Changed line 54 from:

digitalRead() reads the PIN register returns 0 returns 1

to:

digitalRead() reads the PIN register returns 0 returns 1

January 17, 2010, at 06:17 PM by Paul Badger -
Changed lines 48-51 from:

digitalWrite() sets PORT register LOW (PULLUPS OFF) == 0 LOW == 0

                                     HIGH (PULLUPS ON) ==  1         HIGH == 1

to:

digitalWrite() sets PORT register LOW (PULLUPS OFF) == 0 LOW == 0

                                     HIGH (PULLUPS ON) ==  1             HIGH == 1

January 17, 2010, at 06:17 PM by Paul Badger -
Changed lines 52-53 from:
                      Voltage at Pin        Voltage <           |          Voltage > 2.5
to:
                      Voltage at Pin        Voltage < 2.5       |          Voltage > 2.5
January 17, 2010, at 06:16 PM by Paul Badger -
Changed lines 52-53 from:
                      Voltage at Pin    Voltage < 2.5           |          Voltage > 2.5
to:
                      Voltage at Pin        Voltage <           |          Voltage > 2.5
January 17, 2010, at 06:16 PM by Paul Badger -
Changed lines 52-54 from:
                      Voltage at Pin    Voltage < 2.5          |          Voltage > 2.5

digitalRead() reads the PIN register returns 0 returns 1

to:
                      Voltage at Pin    Voltage < 2.5           |          Voltage > 2.5

digitalRead() reads the PIN register returns 0 returns 1

January 17, 2010, at 06:15 PM by Paul Badger -
Changed lines 52-53 from:
                  Voltage at Pin           Voltage < 2.5          |   Voltage > 2.5
to:
                      Voltage at Pin    Voltage < 2.5          |          Voltage > 2.5
January 17, 2010, at 06:14 PM by Paul Badger -
Changed lines 46-47 from:
                                         INPUT STATE        |      OUTPUT STATE
to:
                                             INPUT STATE        |      OUTPUT STATE
Changed lines 52-53 from:
            Voltage at Pin           Voltage < 2.5          |   Voltage > 2.5
to:
                  Voltage at Pin           Voltage < 2.5          |   Voltage > 2.5
January 17, 2010, at 06:13 PM by Paul Badger -
Changed lines 46-47 from:
                                     INPUT STATE        |     OUTPUT STATE
to:
                                         INPUT STATE        |      OUTPUT STATE
Changed lines 52-53 from:
            Voltage at Pin           Voltage < 2.5      |   Voltage > 2.5
to:
            Voltage at Pin           Voltage < 2.5          |   Voltage > 2.5
January 17, 2010, at 06:12 PM by Paul Badger -
Changed lines 48-51 from:

digitalWrite() sets PORT register PULLUPS OFF == 0 LOW == 0

                                     PULLUPS ON == 1          HIGH == 1

to:

digitalWrite() sets PORT register LOW (PULLUPS OFF) == 0 LOW == 0

                                     HIGH (PULLUPS ON) ==  1         HIGH == 1

January 17, 2010, at 06:06 PM by Paul Badger -
Changed lines 48-51 from:

digitalWrite() sets PORT register PULLUPS OFF == 0 LOW == 0

                                     PULLUPS ON == 1        HIGH == 1

to:

digitalWrite() sets PORT register PULLUPS OFF == 0 LOW == 0

                                     PULLUPS ON == 1          HIGH == 1

January 17, 2010, at 06:05 PM by Paul Badger -
Changed lines 46-47 from:
                                     INPUT STATE      |    OUTPUT STATE
to:
                                     INPUT STATE        |     OUTPUT STATE
Changed lines 52-54 from:
            Voltage at Pin           Voltage < 2.5    |   Voltage > 2.5

digitalRead() reads the PIN register returns 0 returns 1

to:
            Voltage at Pin           Voltage < 2.5      |   Voltage > 2.5

digitalRead() reads the PIN register returns 0 returns 1

January 17, 2010, at 06:04 PM by Paul Badger -
Changed lines 52-53 from:

Voltage at Pin Voltage < 2.5 | Voltage > 2.5

to:
            Voltage at Pin           Voltage < 2.5    |   Voltage > 2.5
January 17, 2010, at 06:02 PM by Paul Badger -
Changed lines 89-91 from:
to:
January 17, 2010, at 06:01 PM by Paul Badger -
Changed lines 85-86 from:
to:
January 17, 2010, at 05:58 PM by Paul Badger -
Changed lines 65-66 from:

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or pulldown resistor (resistor to ground) on the input, with 10K being a common value.

to:

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or a pulldown resistor (resistor to ground) on the input, with 10K being a common value.

January 17, 2010, at 05:57 PM by Paul Badger -
Changed line 23 from:

Register Settings Block Diagram

to:

Register Settings Diagram

Changed line 54 from:

digitalRead() reads the PIN register reports 0 reports 1

to:

digitalRead() reads the PIN register returns 0 returns 1

January 17, 2010, at 05:56 PM by Paul Badger -
Changed lines 49-51 from:
                                     PULLUPS ON == 1        HIGH == 1@]

to:
                                     PULLUPS ON == 1        HIGH == 1

Changed lines 55-56 from:
to:

@]

January 17, 2010, at 05:55 PM by Paul Badger -
Changed lines 52-54 from:
                                     Voltage < 2.5   |   Voltage > 2.5

to:

Voltage at Pin Voltage < 2.5 | Voltage > 2.5

January 17, 2010, at 05:54 PM by Paul Badger -
Changed lines 55-56 from:

digitalRead() READS the PIN register

to:

digitalRead() reads the PIN register reports 0 reports 1

January 17, 2010, at 05:53 PM by Paul Badger -
Added lines 51-56:
                                     Voltage < 2.5   |   Voltage > 2.5

digitalRead() READS the PIN register

January 17, 2010, at 05:49 PM by Paul Badger -
Changed lines 49-54 from:
                                     PULLUPS ON == 1        HIGH == 1

@]

to:
                                     PULLUPS ON == 1        HIGH == 1@]
January 17, 2010, at 05:48 PM by Paul Badger -
Changed lines 26-27 from:
                     PULLUPS ON      PORTx == 1
to:
                      PULLUPS ON     PORTx == 1
January 17, 2010, at 05:47 PM by Paul Badger -
Changed lines 25-27 from:
                                   DDRx  == 0
                   PULLUPS ON      PORTx == 1
to:
                                     DDRx  == 0
                     PULLUPS ON      PORTx == 1
Changed lines 29-35 from:
                                   DDRx  == 0
                   PULLUPS OFF     PORTx == 0

                                   DDRx  == 1
                     PIN HIGH      PORTx == 1
to:
                                     DDRx  == 0
                     PULLUPS OFF     PORTx == 0

                                     DDRx  == 1
                       PIN HIGH      PORTx == 1
Changed lines 37-43 from:
                                   DDRx  == 1
                      PIN LOW      PORTx == 0

pinMode() sets the DDR register INPUT == 0

                                   OUTPUT == 1
to:
                                     DDRx  == 1
                        PIN LOW      PORTx == 0

pinMode() sets the DDR register INPUT == 0

                                     OUTPUT == 1
Changed lines 46-51 from:
                                   INPUT STATE      |    OUTPUT STATE

digitalWrite() sets PORT register PULLUPS OFF == 0 LOW == 0

                                   PULLUPS ON == 1        HIGH == 1

to:
                                     INPUT STATE      |    OUTPUT STATE

digitalWrite() sets PORT register PULLUPS OFF == 0 LOW == 0

                                     PULLUPS ON == 1        HIGH == 1

January 17, 2010, at 05:46 PM by Paul Badger -
Changed lines 48-51 from:

digitalWrite() sets PORT register PULLUPS ON == 1 HIGH == 1

                                   PULLUPS OFF == 0       LOW == 0

to:

digitalWrite() sets PORT register PULLUPS OFF == 0 LOW == 0

                                   PULLUPS ON == 1        HIGH == 1

January 17, 2010, at 05:44 PM by Paul Badger -
Changed lines 42-45 from:

pinMode() sets the DDR register OUTPUT == 1

                                   INPUT  == 0

to:

pinMode() sets the DDR register INPUT == 0

                                   OUTPUT == 1

January 17, 2010, at 05:41 PM by Paul Badger -
Deleted line 45:
January 17, 2010, at 05:40 PM by Paul Badger -
Changed lines 49-52 from:

digitalWrite() sets PORT register PULLUPS ON == 1 HIGH == 1 /

                                   PULLUPS OFF == 0    LOW == 0 / 

to:

digitalWrite() sets PORT register PULLUPS ON == 1 HIGH == 1

                                   PULLUPS OFF == 0       LOW == 0

January 17, 2010, at 05:40 PM by Paul Badger -
Changed lines 47-52 from:
                                   INPUT STATE     | OUTPUT STATE

digitalWrite() sets PORT register PULLUPS ON == 1 HIGH == 1 /

                                   PULLUPS OFF == 0 LOW == 0 / 

to:
                                   INPUT STATE      |    OUTPUT STATE

digitalWrite() sets PORT register PULLUPS ON == 1 HIGH == 1 /

                                   PULLUPS OFF == 0    LOW == 0 / 

January 17, 2010, at 05:39 PM by Paul Badger -
Changed lines 46-49 from:

digitalWrite() sets PORT register HIGH == 1 / PULLUPS ON == 1

                                   LOW == 0 / PULLUPS OFF == 0

to:
                                   INPUT STATE     | OUTPUT STATE

digitalWrite() sets PORT register PULLUPS ON == 1 HIGH == 1 /

                                   PULLUPS OFF == 0 LOW == 0 / 

January 17, 2010, at 05:35 PM by Paul Badger -
Added lines 25-32:
                                   DDRx  == 0
                   PULLUPS ON      PORTx == 1

PIN SET AS INPUT

                                   DDRx  == 0
                   PULLUPS OFF     PORTx == 0

Changed lines 41-50 from:
                                   DDRx  == 0
                   PULLUPS ON      PORTx == 1

PIN SET AS INPUT

                                   DDRx  == 0
                   PULLUPS OFF     PORTx == 0

to:
Changed lines 45-50 from:

digitalWrite sets PORT register HIGH == 1 / PULLUPS ON = 1

                                   LOW == 0 / PULLUPS OFF

to:

digitalWrite() sets PORT register HIGH == 1 / PULLUPS ON == 1

                                   LOW == 0 / PULLUPS OFF == 0

Changed lines 53-56 from:

Pins Configured as INPUT

to:

Properties of Pins Configured as INPUT

Changed lines 75-76 from:

Pins Configured as OUTPUT

to:

Properties of Pins Configured as OUTPUT

January 17, 2010, at 05:30 PM by Paul Badger -
Added lines 40-51:

pinMode() sets the DDR register OUTPUT == 1

                                   INPUT  == 0

digitalWrite sets PORT register HIGH == 1 / PULLUPS ON = 1

                                   LOW == 0 / PULLUPS OFF

Added lines 55-56:
January 17, 2010, at 05:25 PM by Paul Badger -
Changed lines 23-36 from:

Pins Configured as INPUT

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading an LED as a photodiode, or reading an analog sensor with a scheme such as RCTime.

This also means however, that input pins with nothing connected to them, or with wires connected to them that are not connected to other circuits, will report seemingly random changes in pin state, picking up electrical noise from the environment, or capacitively coupling the state of a nearby pin.

Pullup Resistors

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or pulldown resistor (resistor to ground) on the input, with 10K being a common value.

There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed in the following manner.

to:

Register Settings Block Diagram

Changed lines 25-26 from:

pinMode(pin, INPUT); // set pin to input digitalWrite(pin, HIGH); // turn on pullup resistors

to:
                                   DDRx  == 1
                     PIN HIGH      PORTx == 1

PIN SET AS OUTPUT

                                   DDRx  == 1
                      PIN LOW      PORTx == 0

                                   DDRx  == 0
                   PULLUPS ON      PORTx == 1

PIN SET AS INPUT

                                   DDRx  == 0
                   PULLUPS OFF     PORTx == 0
Added lines 42-59:

Pins Configured as INPUT

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading an LED as a photodiode, or reading an analog sensor with a scheme such as RCTime.

This also means however, that input pins with nothing connected to them, or with wires connected to them that are not connected to other circuits, will report seemingly random changes in pin state, picking up electrical noise from the environment, or capacitively coupling the state of a nearby pin.

Pullup Resistors

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or pulldown resistor (resistor to ground) on the input, with 10K being a common value.

There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed in the following manner.

pinMode(pin, INPUT);           // set pin to input
digitalWrite(pin, HIGH);       // turn on pullup resistors

January 17, 2010, at 04:51 PM by Paul Badger -
Changed lines 17-20 from:

The DDR registers control whether the pins is an an input or output. They may be either read or written.

to:

The setting of the DDR register controls whether the pins is an an input or output. DDR registers may be either read or written.

The setting of the PORT register controls whether the pin is HIGH or LOW, when the pin is in an OUTPUT state. When the pin is configured to an INPUT state, the PORT register controls whether the pin has its pullup resistor set. PORT registers may be either read or written.

The PIN register is a read only register that indicates the electrical condition of the pin. In other words, if the voltage level of the pin is above about 2.5 volts this register will read as a 1, if not it will read as a 0.

January 17, 2010, at 04:42 PM by Paul Badger -
Changed lines 9-10 from:

There are three port registers that control every pin on the Atmega168/328 chip. The lower case x's in the names indicate that these names are common for each port on the chip. This will be more clear if you glance at the Port Manipulation page.

to:

There are three port registers that control every pin on the Atmega168/328 chip. The lower case x's in the names are place holders for individual port letter designations. This will be more clear if you glance at the Port Manipulation page.

January 17, 2010, at 04:39 PM by Paul Badger -
Changed lines 7-8 from:

The best way to really understand the nature of Atmega microcontroller pins used by the Arduino, is to to visualize the underlying port registers in the Atmega chip. These are the memory locations that control the electrical function of the pins. More details on this may be found in the Port Manipulation reference page.

to:

The best way to really understand the nature of Atmega microcontroller pins used by the Arduino, is to understand the underlying port registers in the Atmega chip. These are the memory locations that control the electrical function of the pins. More details on this may be found in the Port Manipulation reference page.

There are three port registers that control every pin on the Atmega168/328 chip. The lower case x's in the names indicate that these names are common for each port on the chip. This will be more clear if you glance at the Port Manipulation page.

Port Registers That Control Atmega (Arduino) Pins

    DDRx - The Port Data Direction Register - read/write
    PORTx - The Port Data Register - read/write
    PINx - The Port Input Pins Register - read only 

The DDR registers control whether the pins is an an input or output. They may be either read or written.

January 17, 2010, at 04:31 PM by Paul Badger -
Changed lines 7-8 from:

The best way to really understand the nature of microcontroller pins is to to visualize the underlying port registers in the Atmega chip. These are the memory locations that control the electrical function of the pins. More details on this may be found in the Port Manipulation reference page.

to:

The best way to really understand the nature of Atmega microcontroller pins used by the Arduino, is to to visualize the underlying port registers in the Atmega chip. These are the memory locations that control the electrical function of the pins. More details on this may be found in the Port Manipulation reference page.

January 17, 2010, at 04:30 PM by Paul Badger -
Changed lines 7-8 from:

The best way to really understand the nature of microcontroller pins is to to visualize the underlying port registers in the Atmega chip. These are the memory locations that control the electrical function of the pins. More details on this may be found in the PortManipulation reference page.

to:

The best way to really understand the nature of microcontroller pins is to to visualize the underlying port registers in the Atmega chip. These are the memory locations that control the electrical function of the pins. More details on this may be found in the Port Manipulation reference page.

January 17, 2010, at 04:30 PM by Paul Badger -
Changed lines 7-8 from:

The best way to really understand the nature of microcontroller pins is to to visualize the underlying port registers in the Atmega chip. These are the memory locations that control the electrical function of the pins. More details on this may be found in the Reference/PortManipulation? reference page.

to:

The best way to really understand the nature of microcontroller pins is to to visualize the underlying port registers in the Atmega chip. These are the memory locations that control the electrical function of the pins. More details on this may be found in the PortManipulation reference page.

January 17, 2010, at 04:29 PM by Paul Badger -
Changed lines 7-8 from:

The best way to really understand the nature of microcontroller pins is to to visualize the underlying port registers in the Atmega chip. These are the memory locations that control the electrical function of the pins. More details on this may be found in the PortManipulation? reference page.

to:

The best way to really understand the nature of microcontroller pins is to to visualize the underlying port registers in the Atmega chip. These are the memory locations that control the electrical function of the pins. More details on this may be found in the Reference/PortManipulation? reference page.

January 17, 2010, at 04:28 PM by Paul Badger -
Added lines 5-8:

Understanding PORT registers

The best way to really understand the nature of microcontroller pins is to to visualize the underlying port registers in the Atmega chip. These are the memory locations that control the electrical function of the pins. More details on this may be found in the PortManipulation? reference page.

October 18, 2009, at 07:46 PM by Paul Badger -
Changed lines 7-8 from:

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading an LED as a photodiode, or reading an analog sensor with a scheme such as RCTime.

to:

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading an LED as a photodiode, or reading an analog sensor with a scheme such as RCTime.

October 18, 2009, at 07:42 PM by Paul Badger -
Changed lines 7-8 from:

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading a phototransistor, or reading an analog sensor with a scheme such as RCTime.

to:

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading an LED as a photodiode, or reading an analog sensor with a scheme such as RCTime.

October 18, 2009, at 07:40 PM by Paul Badger -
Changed lines 9-10 from:

This also means however that input pins with nothing connected to them, or with wires connected to them that are not connected to other circuits, will report seemingly random changes in pin state, picking up electrical noise from the environment, or capacitively coupling the state of a nearby pin.

to:

This also means however, that input pins with nothing connected to them, or with wires connected to them that are not connected to other circuits, will report seemingly random changes in pin state, picking up electrical noise from the environment, or capacitively coupling the state of a nearby pin.

October 18, 2009, at 07:40 PM by Paul Badger -
Changed lines 7-8 from:

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading a phototransistor, or reading an analog sensor with a scheme such as RCTime.

to:

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading a phototransistor, or reading an analog sensor with a scheme such as RCTime.

October 18, 2009, at 07:37 PM by Paul Badger -
Changed lines 7-8 from:

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor.

to:

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor, reading a phototransistor, or reading an analog sensor with a scheme such as RCTime.

October 18, 2009, at 07:35 PM by Paul Badger -
Changed lines 3-4 from:

The digital pins on the Arduino can be configured as either inputs or outputs. This document explains the functioning of the pins in those modes.

to:

The pins on the Arduino can be configured as either inputs or outputs. This document explains the functioning of the pins in those modes. While the title of this document refers to digital pins, it is important to note that vast majority of Arduino (Atmega) analog pins, may be configured, and used, in exactly the same manner as digital pins.

December 29, 2008, at 12:56 AM by Paul Badger -
Changed lines 7-8 from:

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 Mega-ohms in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor.

to:

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 megohm in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor.

October 04, 2008, at 02:15 PM by David A. Mellis -
Changed lines 1-6 from:

Pins

Pins Configured as INPUT

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 Megohms in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor.

to:

Digital Pins

The digital pins on the Arduino can be configured as either inputs or outputs. This document explains the functioning of the pins in those modes.

Pins Configured as INPUT

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 Mega-ohms in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor.

Changed lines 13-14 from:

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor(to +5V), or pulldown resistor (resistor to ground) on the input, with 10K being a common value.

to:

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or pulldown resistor (resistor to ground) on the input, with 10K being a common value.

Changed lines 27-29 from:

Pins Configured as OUTPUT

to:

Pins Configured as OUTPUT

September 08, 2008, at 05:17 AM by Paul Badger -
Changed lines 7-8 from:

This also means however that input pins with nothing connected to them, or with wires connected to them that are not connected to other circuits, will report seemingly random changes in pin state, picking up electrical noise from the environment, or capacitively coupling the state of a nearby pin for example.

to:

This also means however that input pins with nothing connected to them, or with wires connected to them that are not connected to other circuits, will report seemingly random changes in pin state, picking up electrical noise from the environment, or capacitively coupling the state of a nearby pin.

April 02, 2008, at 01:52 AM by Paul Badger -
Changed lines 11-12 from:

Often it is useful, to steer an input pin to a known state if no input is present. This can be done by adding a pullup (resistor to VCC), or pulldown resistor (resistor to ground) on the input, with 10K being a common value.

to:

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor(to +5V), or pulldown resistor (resistor to ground) on the input, with 10K being a common value.

Changed lines 22-24 from:

Note also that the pullup resistors are controlled by the same registers (internal chip memory locations) that control whether a pin is high or low. Consequently a pin that is configured to have pullup resistors turned on when the pin is an INPUT, will have the pin configured as HIGH if the pin is then swtiched to an OUTPUT with pinMode(). This works in the other direction as well, and an output pin that is left in a high state will have the pullup resistors set if switched to an input with pinMode().

to:

Note also that the pullup resistors are controlled by the same registers (internal chip memory locations) that control whether a pin is HIGH or LOW. Consequently a pin that is configured to have pullup resistors turned on when the pin is an INPUT, will have the pin configured as HIGH if the pin is then swtiched to an OUTPUT with pinMode(). This works in the other direction as well, and an output pin that is left in a HIGH state will have the pullup resistors set if switched to an input with pinMode().

March 31, 2008, at 01:05 PM by Paul Badger -
Added lines 7-8:

This also means however that input pins with nothing connected to them, or with wires connected to them that are not connected to other circuits, will report seemingly random changes in pin state, picking up electrical noise from the environment, or capacitively coupling the state of a nearby pin for example.

Changed lines 11-12 from:

Often it is useful however, to steer an input pin to a known state if no input is present. This can be done by adding a pullup (resistor to VCC), or pulldown resistor (resistor to ground) on the input, with 10K being a common value.

to:

Often it is useful, to steer an input pin to a known state if no input is present. This can be done by adding a pullup (resistor to VCC), or pulldown resistor (resistor to ground) on the input, with 10K being a common value.

Changed lines 20-24 from:

Note that the pullup resistors provide enough current to dimly light an LED connected to a pin that has been configured as an input. If LED's in a project seem to be working, but very dimly, this is likely what is going on, and you have forgotten to use pinMode to change the pins to outputs.

Note also that the pullup resistors are controlled by the same registers (internal chip memory locations) that control whether a pin is high or low. Consequently a pin that is configured to have pullup resistors turned on when the pin is an INPUT, will have the pin configured as HIGH if the pin is then swtiched to an OUTPUT. This works in the other direction as well and an output pin that is left in a high state will have the pullup resistors set if switched to an input with pinMode().

to:

Note that the pullup resistors provide enough current to dimly light an LED connected to a pin that has been configured as an input. If LED's in a project seem to be working, but very dimly, this is likely what is going on, and the programmer has forgotten to use pinMode() to set the pins to outputs.

Note also that the pullup resistors are controlled by the same registers (internal chip memory locations) that control whether a pin is high or low. Consequently a pin that is configured to have pullup resistors turned on when the pin is an INPUT, will have the pin configured as HIGH if the pin is then swtiched to an OUTPUT with pinMode(). This works in the other direction as well, and an output pin that is left in a high state will have the pullup resistors set if switched to an input with pinMode().

March 31, 2008, at 12:56 PM by Paul Badger -
Added lines 7-8:

Pullup Resistors

Changed lines 18-20 from:

Note that the pullup resistors provide enough current to dimmly light an LED connected to a pin that has been configured as an input. If LED's in a project seem to be working, but very dimmly, this is likely what is going on, and you have forgotten to use pinMode to change the pins to outputs.

to:

Note that the pullup resistors provide enough current to dimly light an LED connected to a pin that has been configured as an input. If LED's in a project seem to be working, but very dimly, this is likely what is going on, and you have forgotten to use pinMode to change the pins to outputs.

Note also that the pullup resistors are controlled by the same registers (internal chip memory locations) that control whether a pin is high or low. Consequently a pin that is configured to have pullup resistors turned on when the pin is an INPUT, will have the pin configured as HIGH if the pin is then swtiched to an OUTPUT. This works in the other direction as well and an output pin that is left in a high state will have the pullup resistors set if switched to an input with pinMode().

March 08, 2008, at 04:42 AM by Paul Badger -
Added lines 25-26:
March 08, 2008, at 04:41 AM by Paul Badger -
Changed lines 23-24 from:

Short circuits on Arduino pins, or attempting to run high current devices from them, can damage or destroy the output transistors in the pin, or damage the entire Atmega chip. Often this will result in a "dead" pin in the microcontroller but the remaining chip will still function adequately. For this reason it is a good idea to connect OUTPUT pins to other devices with 100Ω to 1k resistors.

to:

Short circuits on Arduino pins, or attempting to run high current devices from them, can damage or destroy the output transistors in the pin, or damage the entire Atmega chip. Often this will result in a "dead" pin in the microcontroller but the remaining chip will still function adequately. For this reason it is a good idea to connect OUTPUT pins to other devices with 470Ω or 1k resistors, unless maximum current draw from the pins is required for a particular application.

March 08, 2008, at 04:39 AM by Paul Badger -
Changed lines 23-24 from:

Short circuits on Arduino pins, or attempting to run high current devices from them, can damage or destroy the output transistors in the pin, or damage the entire Atmega chip. Often this will result in a "dead" pin in the microcontroller but the remaining chip will still function adequately. For this reason it is a good idea to connect OUTPUT pins to other devices with 470Ω or 1k resistors.

to:

Short circuits on Arduino pins, or attempting to run high current devices from them, can damage or destroy the output transistors in the pin, or damage the entire Atmega chip. Often this will result in a "dead" pin in the microcontroller but the remaining chip will still function adequately. For this reason it is a good idea to connect OUTPUT pins to other devices with 100Ω to 1k resistors.

February 14, 2008, at 04:13 AM by David A. Mellis -
Added lines 1-24:

Pins

Pins Configured as INPUT

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode(). Pins configured as inputs are said to be in a high-impedance state. One way of explaining this is that input pins make extremely small demands on the circuit that they are sampling, say equivalent to a series resistor of 100 Megohms in front of the pin. This means that it takes very little current to move the input pin from one state to another, and can make the pins useful for such tasks as implementing a capacitive touch sensor.

Often it is useful however, to steer an input pin to a known state if no input is present. This can be done by adding a pullup (resistor to VCC), or pulldown resistor (resistor to ground) on the input, with 10K being a common value.

There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed in the following manner.

pinMode(pin, INPUT);           // set pin to input
digitalWrite(pin, HIGH);       // turn on pullup resistors

Note that the pullup resistors provide enough current to dimmly light an LED connected to a pin that has been configured as an input. If LED's in a project seem to be working, but very dimmly, this is likely what is going on, and you have forgotten to use pinMode to change the pins to outputs.

Pins Configured as OUTPUT

Pins configured as OUTPUT with pinMode() are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can source (provide positive current) or sink (provide negative current) up to 40 mA (milliamps) of current to other devices/circuits. This is enough current to brightly light up an LED (don't forget the series resistor), or run many sensors, for example, but not enough current to run most relays, solenoids, or motors.

Short circuits on Arduino pins, or attempting to run high current devices from them, can damage or destroy the output transistors in the pin, or damage the entire Atmega chip. Often this will result in a "dead" pin in the microcontroller but the remaining chip will still function adequately. For this reason it is a good idea to connect OUTPUT pins to other devices with 470Ω or 1k resistors.

Share