SACC

/ / navigation

Introduction

Exercise 1
Exercise 2
Exercise 3

/ / Variable Resistance



potentiometer.jpg

A Voltage Divider

  • There is a source of voltage

  • There is a source of variable resistance

  • There is another source of variable resistance inside the chip


analogin-pot.jpg

The variable resistor and the fixed resistor divide the voltage into two parts. The variable resistor feeds a varying voltage to the microcontroller pin. The fixed resistor provides a path to ground. The voltage where the resistors meet (the pin) will vary with the ratio of the resistors's values. When the resistors are equal, the voltage on the pin will be half the source voltage.
bb_dualflex_b.jpg

The circuit above works for any variable resistor. It's a voltage divider.
In the image above, there are two voltage dividers, one on analog-in 0 and one on analog-in 1. The fixed resistor in each circuit should have the same order of magnitude as the variable resistor's range. For example, if you're using a flex sensor with a range of 50 - 100 kilohms, you might use a 47Kohm or a 100Kohm fixed resistor. If you're using a force sensing resistor that goes from inifinity ohms to 10 ohms, but most of its range is between 10Kohms and 10 ohms, you might use a 10Kohm fixed resistor.



A potentiometer is a simple device that provides a variable resistance, which you can read into the Arduino board.

When the pot is up all the way, the chip gets all 5 volts. When the pot is down all the way, the chip gets 0 volts.




Along with the digital pins the Arduino has, it also has 6 analog input pins. These inputs take a voltage between 0 and 5 volts and convert it to a number between 0 and 1024.

To use a potentiometer, connect three wires to the Arduino board.

  1. The first (one of the outer pins of the potentiometer) goes to ground.
  2. The middle pin goes to an analog input pin.
  3. The third (the other outer pin of the potentiometer) goes to 5 volts .

If you get weird readings use a pull-down resistor.

The pull-down resistor avoids a short circuit when the variable resistance is set to zero.

By turning the shaft of the potentiometer, you change the amount of resistence on either side of the wiper which is connected to the center pin of the potentiometer. This changes the relative closeness of that pin to 5 volts and ground, giving you a different analog input. When the shaft is turned all the way in one direction, there are 0 volts going to the pin, which is read as 0. When the shaft is turned all the way in the other direction, there are 5 volts going to the pin and the chip reads 1024. In between, analogRead() returns a number between 0 and 1024 that is proportional to the amount of voltage being applied to the pin.