User Manual

3.c. Orangutan Digital I/O Functions
Overview
This section of the library provides commands for using the AVR’s pins as generic digital inputs and
outputs. Every pin on the AVR that has a name starting with P, followed by a letter and number (e.g.
PC2) can be configured as a digital input or digital output. The program running on the AVR can
change the configuration of these pins on the fly using the functions in this library.
Complete documentation of these functions can be found in Section 4 of the Pololu AVR Library
Command Reference [https://www.pololu.com/docs/0J18].
Digital outputs
When a pin is configured as a digital output, the AVR is either driving it low (0 V) or high (5 V). This
means that the pin has a strong electrical connection to either 0 V (GND) or 5 V (VCC). An output pin
can be used to send data to a peripheral device or supply a small amount of power (for example, to
light an LED).
Digital inputs
When a pin is configured as a digital input, the AVR can read the voltage on the pin. The reading
is always either low (0) or high (1). Basically, a low reading means that the voltage is close to 0 V,
while a high reading means that the voltage is close to 5 V (see the DC characteristics section of your
AVR’s datasheet for details). Note that when we talk about absolute voltages in this document, we are
assuming that the voltage of the ground (GND) line is defined to be 0 V.
Every I/O pin on the AVR comes with an internal 20–50 kilo-ohm pull-up resistor that can be enabled
or disabled. A pull-up resistor is a resistor with a relatively high resistance that connects between a
pin and the 5 V supply (VCC). If nothing is driving the pin strongly, then the pull-up resistor will pull
the voltage on the pin up to 5 V. Pull-up resistors are useful for ensuring that your input pin reaches a
well-known state when nothing is connected to it. If your input pin has nothing connected to it and the
pull-up resistor is disabled, then it is called a floating pin. In general, it is not recommended to take a
digital reading on a floating pin, because the reading will be unpredictable.
An input pin can be used to read data from a sensor or other peripheral.
When the AVR powers up, all I/O pins are configured as inputs with their pull-up resistors disabled.
125
126
127
print(" "); // overwrite any left over characters
}
}
Pololu AVR C/C++ Library User’s Guide © 2001–2019 Pololu Corporation
3. Functional Overview and Example programs Page 17 of 56