You can find on the arduino uno board. Note that im not going to write code here, but instead focus on the big picture and explanation of what you can do with each pin and this video is focused on arduino uno. But most of the explanations are also valid for any other arduino board. Just maybe with a different amount of pins and different numbers for the pins. So here is a global visual description of all the pins. You can find on an arduino uno board and lets break this down with each type of pin lets get started with ground pins. If there is one thing, and only one thing that you should remember with the ground, it is always connect all grounds of your circuits together and make sure all components are correctly linked to the ground. Ground beings 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 two 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 dont have a common ground, then what does 3.3 volt mean? Is it greater than a 5 volt value? You measure from another point of your circuit, its like measuring the height difference between two persons. If one of them is standing on a box, then the ground reference is not the same, and you cant get a valuable measurement.

If you dont play the two persons on the same level, well, i wont go into more details, but you see the point after ground pins. Another very important type of pins are power pins and for those pins you have two possibilities. You can power your arduino uno board, from an external source and or from the arduino board. You can power on external components, note that the two options are different and you can use them both. At the same time, you can power on your arduino from an external source, while also powering other hardware components from the arduino board. So for the first possibility 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 included when you order an arduino board. You can also use the dc power jack to power, your arduino board with 7 to 12 volt. If you are using some hobby servo motors powered by arduino, for example, you might want to use the dc power jack. The power coming from the usb cable is lower its great for communication between your boards and your computer or other arduino boards, but might be not enough to power. Some real motors, so youve already got two ways to power: your arduino uno board. Now, if you look at the power pins on the circuit here, you will see a v in pin. You can also use this pin to provide 7 to 12 volt to your board, its very practical when you need to use an external power source with no jack connector and, as you can guess, if you use the v in, 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 directly touch around the usb connector is linked to the ground. Now lets have a look at the second possibility, 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 the 3.3 volt and the 5 volt power pins and connect those to the component. You want to power on make sure to use the correct voltage to know which voltage to use simply refer to the data sheet of the external hardware component. Alright, now that we are done with ground and power pins, we arrive at the interesting part with the pins we can use to control hardware components and communicate with the outside lets start with 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, you will use digital pins to read data from some components named sensors and write data to other components named actuators, for example, you can read the state of a push button or modify the color of an led now. How do those pins work? Well, first, you have to know that those pins will operate between 0 and 5 volt. The max voltage will vary depending on the arduino board, for both such as arduino uno mega and nano. The voltage for digital pins is 5 volt for some other bulbs, such as 2a or 0.

The voltage is 3.3 volt. If you need to connect digital pins from two boards, using two different voltages make sure to use a 3.3 volt to 5 volt level shifter. You can either buy one or build one by yourself. So, back to the explanation, a digital pin can have only two states low or high. You can consider them as binary pins. Low means that the voltage on the pin is zero. Volt high means vcc, which is 5v before you actually use a digital pin. You need to configure its mode. A digital pin can either be on input mode or output mode. When, in input mode, you will use it to read data when in output mode, you will use it to write data after youve set the mode for the pin, usually in the setup function of your arduino program with pin mode, you will be able to read or Write the state of the pin with digital, read or digital right, and then here the states, high and low, actually correspond to 5 volt for high and 0 volt for low and now for some of the digital pins. You can also use the pwm functionality, a pwm or pulse width. Modulation is basically a way to get a specific voltage, for example, 4.1 volt, with only high and low states, so only 5 volt and 0 volt states. The pwm creates a pulse running at a given frequency, which is, for example, 500 hertz for arduino uno.

Then a duty cycle parameter will tell what percentage of each pulse is in the high state or in the low state. The frequent change of high low states produces an average voltage output, for example, at a 50 percent duty cycle, which means that 50 percent of the time is high. 50 of the time is low. The output voltage would be about 2.5 volt. Of course, this explanation is already simplified, but thats 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 tilde next to their number. The arduino uno pins compatible with pwm are the pins 3, 5, 6, 9, 10 and 11.. So you have six pins where you can create a pwm using the analogue write 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 an led, you can use the analog write function to modify the brightness of the led so for a digital pin with pwm functionality, you can choose to use it normally with a binary state or to use the pwm only in output Mode and there is yet another functionality available for the digital pins – you can use some of them as interrupt pins in your arduino program for arduino. We know 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 multi threading lets say you connect a push button to an interrupt, pin and also, of course, dont forget to the ground. In your arduino program, you can attach a specific function to be triggered whenever you press on 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 a new content or a specific action to do. Okay, now we are done with digital pins and the different functions they can have. Lets have a look at analog pins. You can find six analog pins on an arduino uno board. You will find them near the power pins and they are easily recognizable from a0 to a5. An analog pin is useful to read values that cant be just 0 or 1. lets say you have a potentiometer and want to get the percentage of the potentiometer value with a digital pin. You could just 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 cant write an analog value through those pins dont forget that, so how is an analog input pin working first, it will receive an input, voltage and read this voltage.

Lets say the pin reads: 2.5 volt, then an adc or analog digital converter will change that analog value into something your arduino program can understand, which is a digital value. The value you get, then, when you read data from an analog input pin, is between 0 and 1023. 0 corresponds to 0 volt and 1023 to 5 volt. All the values in between are proportional. So if you get 512, for example, you know that the voltage is about 2.5 volt and remember that an analog pin can only be used to read analog values. It cant be used to write analog values which we saw with the pwm pwm is reserved for certain digital pins, not for analog pins. This might be confusing at first, but well, thats, basically how it is, and then you can also choose to use an analog pin as a digital pin 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 digital write and digital raid functions and it will work perfectly the same, but note again that in this case you cant use the pwm functionality only the default digital pin functionalities, alright thats it for the main functions of the digital and analog Pins of the arduino board, but actually there is more to it. There are three main communication protocols you can use with an arduino uno board through the pins of the circuit, uart, spi and i2c.

Those protocols will allow you to transfer more complex information faster between your computer and your arduino are between two arduino boards, or even between an arduino and an external component. That supports one of those communication protocols. For example, a sensor here im going to give you a very quick overview with not too many details. Lets start with uart new art is one of the most used protocols with arduino when you connect your arduino uno board to your computer and communicate via the serial library. Well, you are actually using new art. You can also find the two required bits for uart directly on the arduino uno board on the pins 0 and 1.. You can see rx and tx r stands for reception and t for transmission. This is a bi directional communication. The two uarts that you see here are actually the same. So if you use the pins for uart, dont use the serial through usb in some other arduino boards, like arduino mega, there are several different available uarts, but for arduino uno. You just have one now to connect the component to the arduino uno, pins and use cell communication. You will need four wires, one between the rx of the component and the tx of the arduino another one between the tx of the component and the rx of the arduino. And now, if the component is not powered externally, we need one wire to power it from the power pins of the arduino and, of course, one wire to connect the ground after uart lets.

Focus on i2c i2c is quite useful to read data from some sensors that will only communicate through i2c for this protocol. There is absolutely no indication on the arduino uno board, so you can see here on the top. You have two pins for i2c and also the a4 and a5 pins sda will be used to transfer the data and scl is used for the clock of the protocol, but note that there is only one i2c module with two choices for which pins you want to Use so remember, dont use the two sda pins or the two scl pins. At the same time now to connect a component to the arduino with i to say, you will need to use four wires, one to connect the scl pin, which is the clock another one for the sda pin for the data one to power on the components on The bus and want to make the common ground and the last protocol spi as for i2c, the spi protocol, is quite useful to communicate with components which only have an spi interface and quick note here. The spi communication speed is faster than for eye to see, but it is not suited when you have a wire which is more than a few centimeters, because the accuracy of the data transfer will become bad quite quickly with the wire distance. So if you can choose take spi for speed, but i to see if you need a longer wire for spi, you have four special functions on four of the digital pins.

You can see here: digital pin 13 with sck, which is the clock for the spi protocol. Digital pin 12 with miso, which means master in slave art, basically to receive data from the external component. Then you have digital pin 11 with mozi, which means master out slave in basically to send data to the external component and digital pin 10 with cs, which means chip select. So you can enable the communication with the component. The wire system for connecting devices with spi pin is a little bit more complex. Here. You will need six wires minimum, so one for the sck pin for the clock, one for the miso pin one for the mozi pin, then one for each csrss, which is chip, select or slave select, pin. So for one device you connect, which we call a slave. You will need one wire and for each additional slave here on the cs. Pin you will need to add another wire and to get more cs pins. You can actually use other digital pins. Just for that, and then of course, you will need two more wires, one for powering the component and one for the common ground. Well now you have a complete overview of the arduino pins and what you can do with them use this video as a quick recap whenever you need it and if you feel lost with all that information and you want to get started with the arduino pins, then What i recommend is to first use the digital and enable pins with their primary functionality, then to start to work with, interrupts and pwm, and finally, there is an infinite number of sensors and actuators.

You can connect to your arduino board using different communication protocols. If you liked this video subscribe to get more tutorials like this in the future, also check out my online courses, so you can learn arduino, step by step in an efficient way by practicing and directly going to the point links in the description.