The Arduino Uno board has over 20 pins that you can use for many different applications. In this post I’ll give you a complete and practical overview of the main Arduino Uno pins.
If you’re starting with Arduino, or if you’re already a software developer and want to learn more about the bridge between software and hardware on an Arduino board, then you’ve come to the right place!
In this post you’ll see :
- What are the pins you can use
- What you can do with them
- And some tips on how to connect other devices to your Arduino pins
I’ll also give you some examples of sensors/actuators that you can use with each pin functionality.
This post is focused on Arduino Uno board, but most of the explanations (except for the pin numbers on the circuit board) are also valid for any other Arduino board.
>> Watch this video as an additional resource to this article:
You are learning how to use Arduino to build your own projects?
Check out Arduino For Beginners and learn step by step.
Get this course for FREE for 14 days! Just click on the link above.
After watching the video, subscribe to the Robotics Back-End Youtube channel so you don’t miss the next tutorials!
Arduino Uno pin diagram
Here’s a global visual description of all the pins you can find on an Arduino Uno board.
You may find that quite difficult to understand at first. So, let’s break down each kind of pin, one by one.
If there is one thing, and only one thing that you should remember with the ground, it’s: always connect all grounds of your circuits together, and make sure all components are correctly linked to the ground. Ground pins are often represented by GND on schematics.
The ground is essential for the Arduino board to measure and set any voltage. Basically a voltage is a difference of potential between 2 points: here you take the ground and another point.
So, if everything in your circuit is connected to the same ground, all the voltages can be compared and their value is relevant. If you don’t have a common ground, then what does 3.3V mean ? Is is greater than a 5V value you measured from another point of your circuit ?
It’s like measuring the height difference between 2 persons: if one of them is standing on a box, then the ground reference is not the same. And you can’t get a valuable measurement if you don’t place the 2 persons on the same level.
Well, I won’t go into more details, but you see the point.
Arduino Power pins
Power goes 2 ways:
- You have to power your Arduino Uno board from an external source
- You can also power some components plugged to your board
Powering the Arduino Uno board
For powering the Arduino Uno board, you have different options. The first one is simply to connect your Arduino board to your computer using a USB cable – usually you get one when you order an Arduino board.
You can also use the DC power jack to power your Arduino board with 7-12V. If you are using some hobby servomotors powered by your Arduino, you might want to use the DC power jack. The power coming from the USB cable is lower. It’s great for communication between your board and your computer (or other Arduino boards), but might be not enough to power some real motors.
So, you’ve already got 2 ways to power your Arduino Uno board. Now, if you look at the power pins on the circuit, you’ll see a Vin pin.
You can use this pin to provide 7-12V to your board. Very practical when you need to use an external power source and connect it directly to your board. And, as you can guess, if you use the Vin, you also need to use the ground correctly, by connecting it to the ground of the external power source.
Note that the USB and DC power jack already have the ground integrated and which connects to anything you plug on them. In fact, the metal part that you can touch around the USB connector is directly linked to the ground!
Powering components from the Arduino Uno power pins
As you can guess, whenever you connect an external component to your Arduino Uno board, you need to connect it first to the ground.
Then you can use several different pins to power it on. Among them are the 3.3V and 5V power pins.
Note – this is important – that the Arduino Uno is operating under 5V. So, for every output pin that we’ll see in the following of this post, be sure to remember that. If you plug a 3.3V component to a 5V power source, you might damage the component.
There are 2 alternatives to that: use the 3.3V power source from the Arduino (integrated voltage bridge), or use 5V with a voltage level shifter. You can easily connect a 3.3V to a 5V component, provided that you transform the voltage between them, using resistors or directly a level shifter component.
Arduino Digital pins
You can find 14 digital pins on an Arduino Uno board. They are easily recognizable, from 0 to 13 on the circuit board.
Reading/Writing on digital pins
You’ll use digital pins to read data from some components (sensors) and write data to other components (actuators).
A digital pin can have only 2 states: LOW or HIGH. You can consider them as binary pins.
LOW means that the voltage on the pin is 0V. HIGH means Vcc, which is 5V here for Arduino Uno.
Before you can actually use a digital pin, you need to configure its mode. A digital pin can either be on INPUT more or OUTPUT mode. When in INPUT mode, you’ll use it to read data. When in OUTPUT mode, you’ll use it to write data.
After you’ve set a mode for the pin – usually in the setup() function of your Arduino program with pinMode() – you’ll be able to read/write the state of the pin with digitalRead()/digitalWrite().
If you have set the pin to INPUT mode, then you can read its state, which will be either HIGH or LOW.
When reading, any voltage applied to the pin lower than 0.8V will be considered as LOW, and any voltage greater than 2V will be considered as HIGH. Thus, I stress again that you should correctly connect all the grounds in your circuit together, or else the Arduino Uno won’t be able to read a valuable information! If you don’t get reliable and stable data, always first check about the ground, it’s very likely that the problem is coming from there.
For examples of how to use digital pins to control a component, check out this Arduino LED tutorial.
For how to use digital pins to read data from a sensor, check out this Arduino push button tutorial.
And if you want to go to a more advanced level with digital pins, check out how to make digitalWrite() faster.
Some of the digital pins can be used to write a PWM.
A PWM (Pulse Width Modulation) is basically a way to get a specific voltage (ex: 4.1V) with only HIGH/LOW (5V/0V) states. The PWM creates a pulse running at a given frequency – 500Hz for Arduino Uno. Then, a duty cycle parameter will tell what percentage of each pulse is in the HIGH state or LOW state.
The frequent change of HIGH/LOW states produces an average voltage output. For example, at a 50% duty cycle (50% of the time HIGH, 50% of the time LOW), the output voltage would be 2.5V.
Of course, this explanation is really simplified, but that’s all you need to know to get started with the Arduino PWM.
Now, you can use the PWM only on some digital pins, which have a “~” next to their number. The Arduino Uno pins compatible with PWM are the pins 3, 5, 6, 9, 10 and 11. So you have 6 pins where you can create a PWM, using the analogWrite() function.
This can be quite useful to control some actuators that require a fine voltage tuning, and are not only switched on or off.
If we take the example of a LED, you can use the analogWrite() function to modify the brightness of the LED.
And… There is another available functionality for the digital pins! You can use some of them as interrupt pins in your Arduino program.
For Arduino Uno, the choice for those pins is quite limited. Only digital pins 2 and 3 can be used as interrupt pins.
So, how is it working ?
When you create an Arduino program, you have to know that your code is running line by line, with no possible multithreading.
Let’s say you connect a push button to an interrupt pin (and to the ground!). In your Arduino program, you can attach a specific function to be triggered whenever you press the button. So, instead of having to continuously read the button state, you can directly use the interrupt behavior to launch your function. Think of it as a push notification, just like on your phone. It tells you when there is new content, or a specific action to do. Learn how to use Arduino Interrupts in your code.
However, this doesn’t mean that you have solved the multithreading issue. When the execution of the program switches to your function called by an interrupt, it will also stop the execution of the current program and come back to it only after the interrupt function has finished.
If you want to learn more about how to multitask with Arduino, check out this complete tutorial on this subject.
Arduino Analog pins
You can find 6 analog pins on an Arduino Uno board. You’ll find them near the power pins, and they’re easily recognizable, from A0 to A5.
Read a value from an analog pin
An analog pin is useful to read values that can’t be just 0 or 1. Let’s say you have a potentiometer and want to get the percentage of the potentiometer value. With a digital pin you could know when the potentiometer is at minimum and maximum position, but nothing else. With analog pins, you have all the values in between.
Note that the analog functionality on those pins is only for reading. Usually they are even called “Analog input pins”. You can’t write an analog value through those pins, don’t forget that!
So, how is an analog input pin working ?
First, it will receive an input voltage and read this voltage. Let’s say the pin reads 2.5V. Then, an ADC (Analog Digital Converter) will change that analog value into something your Arduino program can understand – a digital value.
The Arduino Uno board has a 10 bits ADC. The resolution can be different if you use other Arduino boards. So, what does 10 bits mean ? Simply that the resolution is 2^10 = 1024. Thus, the value you get when you read data from an analog input pin is between 0 and 1024.
Coming back to our 2.5V example: 2.5V is 50% of 5V (Vcc). In your Arduino program, you will then get the value 512. From this value, you can easily reverse the computation and get the information about the voltage that was applied.
Also – and it can be quite confusing at first – remember that the analogWrite() function for PWM is only available for some of the digital pins, and not for analog pins at all.
Using an analog pin as a digital pin
Even if you can only read from an analog pin, you can also choose to use it as a “simple” digital pin. (but the opposite is not true)
If the pin can read any value between 0 and 5V, then it will be able to read just values below 0.8V (LOW) and values above 2V (HIGH).
To use an analog pin as a digital pin, you simply have to set the mode for the pin, as you would do for digital pins in the setup() function of your Arduino program. Then, you can use the digitalWrite() and digitalRead() functions and it will work perfectly.
Communication protocols through Arduino pins
Here is where things start to get interesting. Communication protocols over Arduino Uno pins will allow you to use more advanced sensors and actuators. You’ll create more complex and useful applications.
There are 3 main communication protocols you can use with an Arduino Uno board, through the pins of the circuit: UART, I2C, and SPI.
But… Nothing is displayed on the circuit!
Don’t panic, the communication protocols are using the existing pins on the circuit.
In fact, most of the pins are configurable to use alternate functions, sometimes up to 4 alternate functions for just one pin. But let’s keep things simple here.
Pins for UART – Serial
UART is the most used protocol for Arduino – at least when you begin.
When you connect your Arduino Uno board to your computer, and communicate via the Serial library, well… You are using UART!
You can also find the 2 required pins for UART directly on the Arduino Uno board, on pins 0 and 1: RX and TX. R stands for “reception” and T for “transmission”. This is a bidirectional communication.
Note that the Serial used by USB is the same as the one used with pins 0 and 1. So, if you want to connect another device to the RX/TX pins of your board, remember not to use the Serial through USB.
In some other Arduino boards, like Mega, there are several different available UARTs. But for Arduino Uno, you only have one.
If however, you want to use more UARTs, you can always do that with the SoftwareSerial library. This library allows you to use any other digital pins for UART purpose. Although there is a big difference here: “true” Serial uses hardware functionality of the Arduino Uno board, which is very fast and doesn’t consume much computation power. The SoftwareSerial is the opposite: it compensates for hardware with computation power. So, start with the standard hardware UART first, and then you’ll see if you need more serial ports for your application (in this case I recommend you switch to an Arduino Mega to get many hardware UARTs).
To connect a component to the Arduino Uno pins and use Serial communication, you’ll need 4 cables:
- One between the RX of the component and the TX of the Arduino
- One between the TX of the component and the RX of the Arduino
- If the component is not powered externally, one cable to power it from the power pins of the Arduino
- And… One for connecting the ground
If you’re interested in communicating between a Raspberry Pi board and an Arduino board via Serial, check out this Raspberry Pi Arduino Serial tutorial.
Pins for I2C
I2C is a bus protocol, with a multi-master/multi-slave architecture. But to keep things simple – and most of your applications will just need that – let’s only talk about the one-master/multi-slave part of the architecture.
Basically, imagine a bus of data where all the data goes through. The head of the bus is the master. Now, you can add any new component to the bus, configured as a slave. Also, each component has its own ID.
The master device will send data and requests to a slave device, by communication on the bus and providing the ID of the slave. If the master needs a response, the slave will send back the response to the bus. Once the master has received a response, it can send the next instruction/request.
Usually, you’ll use your Arduino Uno board as the master, and you’ll connect one or several components (usually sensors) to the I2C bus, with each a different ID. On the software side, you’ll use the open source Arduino Wire library.
But, to which Arduino Uno pins should you connect all those components ?
For I2C you can’t see any indication directly on the circuit board.
You’ll need 4 cables to use an I2C bus:
- One to connect the SCL pin (clock)
- Another one for the SDA pin (data)
- One to power on the components on the bus
- And one to make the common ground
Some examples of I2C compatible components:
- MPL3115A2 temperature sensor
- MPU6050 gyroscope + accelerometer sensor
- TCS34725 color sensor
Pins for SPI
SPI is another protocol based on a master-slaves architecture.
You can use it to connect your Arduino board to multiple devices. Note that the communication speed is faster than for I2C and UART, but it’s not suitable for mid-long distance communication (more than a few centimeters for the cable). As for the other communication protocols, you can directly use the open source SPI library on your Arduino programs.
When you’re using an SPI device and want to connect it to some pins on your Arduino board, here are the pins you need to use:
The cable system for connecting devices with SPI pins is a little bit more complex. You need 6 cables minimum:
- SCK pin (clock)
- MISO pin (Master In, Slave Out)
- MOSI pin (Master Out, Slave In)
- One for each CS/SS (Chip Select/Slave Select). For each additional slave, you’ll need to add one more connection to an Arduino pin.
- One for powering the components
- And one for the common ground
Some examples of SPI compatible devices:
- AS5047D magnetic position sensor
- MAX31855 thermocouple-to-digital sensor
Get started with Arduino Uno pins
As you saw in this post, you have a huge number of options when it comes to using Arduino Uno pins.
If you just begin with Arduino, try first to use the digital and analog basic functionalities.
Then, you can start to go further with interrupts, PWM outputs, etc.
And finally, there’s an infinite number of sensors/actuators you can connect to your Arduino Uno board to create your next project!
You can also connect several Arduino boards together, or even a Raspberry Pi board.
Well, now that you have a better understanding of Arduino Uno pins, time to get your hands dirty!
If you don’t have an idea of what to do with all those pins, check out the different devices I introduced as examples in this post, this might be a good way to start and get more ideas.