If you are new to the channel, then please subscribe the channel and hit the bell icon for the latest notifications. In my todays video, i am going to explain how to interface the potentiometer with the arduino board, along with its code. So let us first see what is the meaning of a potentiometer, so the potentiometer is nothing, but it is a variable resistor. As you can see in the picture, it is having three pins now the pin numbers are not actually specified for potentiometer, as it is a variable resistor. So the one end of this potentiometer will be connected to your vcc. That is five volts. The third end, that is the third pin, is connected to the ground, so the these two fixed uh terminals are connected to vcc and ground, and the middle terminal is a variable terminal. So when you vary that potentiometer, then the value of the potentiometer will change. Now, when you rotate this potentiometer and when it is connected between 0 and 5 volts, then it will provide the voltage range from 0 to plus 5 volts. Now the uh. This potentiometer is basically an analog input and therefore the middle terminal of this potentiometer is connected to one of the analog input of the arduino board. Now here i am selecting the pin number a0 of the radio board for connecting this middle terminal of the potentiometer. Now this analog voltage will be then internally converted into the digital by using an internal adc.

Now the internal adc, which is uh used or in this board, is a having a resolution of 10 bits and therefore, when you rotate the pot from 0 volts to 5 volt, then you will get the output as 0 to 1. 0. 2. 3, because 2 raised to 10 is equal to 1 0 to 4 maximum steps, so for starting from 0, the maximum value of the reading will be 1 0 to 3. Now, when you write the code for this potentiometer, then the function for reading these analog values is nothing, but it is a analog. Read function so well. First, read the values of this potentiometer using the analog grid, then internally it will be converted by adc to corresponding values, which ranges from 0 to 1 0 to 3. Now here i am going to display these values on lcd. So let us first see the code for this potentiometer interfacing with the arduino board, along with the lc. So for that let us go to arduino software, and here i will open the code for potentiometer. So this is the code for interfacing of the potentiometer. I will explain the code line by line here. I am going to display the values on lcd and therefore, first i have to add liquid crystal dot h. Therefore, i have written hash include liquid crystal dot h again. The next two statements are related to the lcd. Only that is the pins of rse, d4, d5, d6 and d7 of lcd will be connected to the pin number 12, 11, 5, 4, 3 and 2 of the arduino board.

Now the main thing is here: we are going to uh connect our potentiometer middle terminal to the one of the analog input, and here we are using the input as a0. So first we will write. Integer port is equal to a0. That means we are selecting the line a0 of arduino. Then in the setup loop we will initialize our lcd in the loop. First, we have to read the values using analog, read function, so analog, read, a0 will read the values and those values will be stored in portable and now. Finally, these spot val values will be printed on the lcd and there will be a delay of 1000 milliseconds, which is added at the end of the code. So this is what is a simple code for this interfacing of the potentiometer and now well. Go for the actual demonstration on the hardware, how to connect and get the output. So this is what is the setup for potentiometer interfacing. Ah, this is the potentiometer that i am going to change and the values will change accordingly, so see. I have used here. 1K potentiometer, the one end of this potentiometer is connected to vcc. The another end is connected to the ground and the middle uh point of the potentiometer is connected to a0 terminal of this arduino board, and this is what is my lcd on which you will get the final ring. So now i will download the same program into the arduino board and you will see the different readings when i change the port values so see.

I have downloaded the program, and this is one the one or the starting point of this potentiometer, where it is showing the value equal to zero. Now i will change this spot value and you will find that these reading will change from 0 to 1 0 to 3.. Now i will change this yes, and you will see that the readings will increase and this is the maximum value. So you can see that the value will vary from 0 to 1 0 to 3. So this is what is a simple setup of interfacing the potentiometer and displaying the values on lcd. So guys, if you like my video, then please subscribe the channel, share the video and also share this video with your friends. Thank you guys.