Connect Potentiometer to Arduino Tutorial

Connect Potentiometer to Arduino Tutorial

Potentiometer Is also known as the variable resistance. In this activity, we are controlling led brightness with Arduino and potentiometer which have the option to change the resistance according to the requirement. in this post, we will share how to connect a potentiometer to the Arduino tutorial. It is very important to learn because it will help you to interface with many analog sensors. if you know the basics of the hardware and it’s working then you can upgrade it by yourself. for example, if you do the Arduino potentiometer code then you can also write code for the flex sensor. there is two way to interface the sensor with the Arduino one is digital connection and another is analog. digital output only gives 2 values high and low. so you can use this for a maximum of two conditions. for example, if the value is high light will on and if the value is low the light will off. but in the case of analog output, you have 0 to 1024 different values and there you can make more than 1000 conditions.

connect a potentiometer to the Arduino

This experiment is only to learn you the basic fundamental of analog sensor interfacing. there are many students who struggle with the interface and the connection with the sensor. that’s why we are posting this article to teach them the right way to interface the sensor. because if you are making a project directly without the basics it will be difficult to make the project work. as you can see out sign language glove with the flex sensor which are also the variable resistance-based sensor. but if you have the basics you can connect any of the sensors easily. we observed that more than 80% of students don’t have the basics. we want you to learn each and everything. Arduino pot connection is very easy but you need to extract the value and show it to the serial monitor. without a serial monitor, you can’t observe the potentiometer value. you will experience the live changes on the monitor with the potentiometer.

controlling led brightness with arduino and potentiometer

what is a potentiometer?

A potentiometer is a variable resistor which can adjust their resistivity manually. there are two types of potentiometer rotatory pot and a preset pot. as you can see in the given images.

PRESET POT

 

rotatary pot
Rotatory pot

 

These are used by their application. but mainly the Rotatory pot uses in the projects and products too.

How does the potentiometer works? 

As I have mentioned above that the potentiometer is a variable resistor. variable means we can adjust the resistivity of the system. for example at one point you need 1k resistance and after sometimes you need 3k there. so you can’s change the resistance in the circuit frequently but in this case, you can adjust the resistance by the potentiometer you need to rotate the potentiometer pin. and you will see the changes in the system. the potentiometer has the circular resistance material over the surface and a knob compress on the same material.  the resistivity depends on the path completed by the knob over the resistor surface. for example, if you have traveled in a circular path you are completing the path like a knob over the surface. And this Will vary the value in Arduino Potentiometer value you can use this in any application.

 

Arduino Potentiometer Wiring 

Wiring with the Potentiometer and Arduino is very simple there are only three wires in the Potentiometer. Positive, negative, and output. Connect Arduino 5v pin to the Potentiometer right pin and Arduino and pin connect to the potentiometer left pin. and output pin with the Arduino analog pin. Let see the controlling led brightness  Arduino potentiometer connection in the given diagram. Arduino Potentiometer Wiring / Connection. 

I hope you will understand the wiring easily by the given circuit.

Now we will talk about the Arduino Potentiometer code

Arduino led fading with potentiometer code:-

 void setup()  
 {  
 Serial.begin(9600);  
 pinMode(3,OUTPUT); // LED  
 pinMode(A0,INPUT); // Potentiometer  
 }  
 void loop()  
 {  
 int s=analogRead(A0);  
 int z=map(s,0,1024,0,255);  
 Serial.println(z);  
 analogWrite(3,z);  
 }  

In the above setup known as the void setup and in this setup all the instructions run only one time. and then it will go to another loop known and the main setup. where our code repeats continuously. we are storing the output value of the sensor into the variable s and then map the value with the 0 to 255. because pwm has the 0 to 255 value which comes under the 0 to 5v. which controlling the brightness of the led.

 

This Post Has One Comment

Leave a Reply