Interfacing a Potentiometer Sensor
Hardware
- Arduino UNO
- Potentiometer
- Jumper wires
About ARDUINO
Arduino is a popular open-source development board for engineers and makers to develop electronics projects in an easy way. It consists of both a physical programmable development board (based on AVR series of microcontrollers) and a piece of software or IDE which runs on your computer and used to write and upload the code to the microcontroller board.
About Potentiometer
A potentiometer is a three-terminal resistor with a sliding or rotating contact that forms an adjustable voltage divider. If only two terminals are used, one end and the wiper, it acts as a variable resistor or rheostat.
The measuring instrument called a potentiometer is essentially a voltage divider used for measuring electric potential (voltage); the component is an implementation of the same principle, hence its name.
Potentiometers are commonly used to control electrical devices such as volume controls on audio equipment. Potentiometers operated by a mechanism can be used as position transducers, for example, in a joystick. Potentiometers are rarely used to directly control significant power (more than a watt), since the power dissipated in the potentiometer would be comparable to the power in the controlled load.
Connections
Code
int x = 0;// to define a variable
void setup() {
Serial.begin(9600);// to initialise Serial communication
}
void setup() {
Serial.begin(9600);// to initialise Serial communication
}
void loop() {
x = analogRead(A1);// to define the input of potentiometer into the variable 'x'
Serial.println(x);
if ((x <= 905 ) && (x>=670))// if the potentiometer is turned to a value
{
Serial.println("Turned");// then execute the printing
}
delay(1000);// to Serial print after every 1 second
x = analogRead(A1);// to define the input of potentiometer into the variable 'x'
Serial.println(x);
if ((x <= 905 ) && (x>=670))// if the potentiometer is turned to a value
{
Serial.println("Turned");// then execute the printing
}
delay(1000);// to Serial print after every 1 second
}
No comments:
Post a Comment