Tutorial Contents

Input and Output Pins

Input Output Pins
Input and Output Pins

The input and output pins on the Arduino are the very crux of the platform. The Arduino wouldn't be very useful if it ran clever sketches, but wasn't able to do anything with the results. Similarly, the strength of the Arduino is that it can react to things happening around it - whether it's a button that you press or a change in temperature. These pins are the connectors that enable the Arduino to interact with its environment.

How do the pins work

Firstly, they're connectors - they connect external components to the main microcontroller on the board. So you'll attach one end of a wire to a pin, the other end to a component of some sort. Then in the sketch tell the Arduino what you want to do with that pin - either read information from a sensor (input) or control the behaviour of the component (output).

Secondly, they work using 5 Volt DC signals. So the pin could be delivering a 5V current, be receiving up to a 5V current, or have no current flowing (0V). If you connect a power source that produces more than 5V, the chances are high that you'll start smelling burning - the microcontroller cannot handle higher voltages. The UNO has built-in voltage regulators, so as long as you only use the UNO as a power source for the microcontroller you'll be fine.

Digital Pins

Pins 0-13

These can be set to work as either Input or Output pins - you tell the UNO this in sketches that you write. When I say that they are digital, I mean that they can only have 2 states - they are on or off / high or low / zero or one. For our purposes, we refer to HIGH and LOW - HIGH means a 5V current is flowing through the pin; LOW means no current (i.e. 0V) is flowing through the pin. If the pin is set as an Input, then 5V would be flowing from the circuit into the pin. If the pin is set as an Output, then 5V would be flowing from the pin into the circuit. It's pretty straightforward, but there's nothing like an example to demonstrate this - you'll build one very soon, when you turn to the next chapter.

Analog Pins

Pins A0-A5

These are Input pins only, and are able to detect varying voltages between 0V and 5V. Digital pins, remember, can only detect 5V and 0V; these analog pins can detect 5 milliVolt increments in voltage from 0V up to 5V. We'll get into examples in a few chapters time, but a typical use of this would be to measure temperature. A simple temperature sensor will output a higher voltage when it's warm and a lower voltage when it's cold, in a predictable way - by measuring the voltage you can calculate the temperature.

Power and Ground Pins

3.3V and 5V

These pins output a constant, regulated 3.3V and 5V respectively. Typically you'd use these to power your projects. They aren't designed to deliver a large current, so are generally only suitable for powering electrical components and not mechanical ones. If you think of a battery, this is the "+" side of the battery.

GND

These pins provide connections for Ground, or GND. You may not always use the 5V or 3.3V pins, but you will always use the GND pins to complete your circuits. You can choose to use any of the three GND pins, as they're all connected together. If you think of a battery, this is the "-" side of the battery.

Other Pins and Connectors

For now we're not going to look at the other pins on the board, as we won't need them for this book. I'm referring specifically to the pins labelled AREF, IOREF, RESET and ICSP. If you're super-interested in getting into the detail of these, then there's plenty of detail available on the Arduino website and forums.

Chapter 2 coming soon... Our First Project