Arduino and Processing, Potentiometer

This is an updated version of the Potentiometer post from here.

To build the electronic circuit you need the following parts:

  • a 10kΩ potentiometer(You can use any potentiometer < 100kΩ ),
  • a 1kΩ resistor,
  • and a couple of wires.

A potentiometer is a variable resistor. Between the two outer pins you will always measure the (maximum) value of the resistor, while the variable resistance is measure between the middle and an outer pin. That’s where we connect a wire to measure the voltage. The pull-down resistor avoids a short circuit when the variable resistance is set to zero. The circuit on your breadboard should look something like this:

Working circuit on breadboard

If everything is set up right, you can connect the board to USB port of your computer. The power LED should light up the next step is to export the program, which reads the state of the switch to the board. Open the ap_ReadAnalog.pde file in Arduino set the right serial port (from the menu Tools->Serial Port), compile the program, and then click on the Upload icon () to send the program to the board.To check if everything works fine so far, turn the potentiometer to both extremes: the LED should light up/turn off when the potentiometer reaches (approximately) its middle position. If that works fine, you can then download and unzip pa_Potentiometer.zip and open the file pa_Potentiometer.pde in Processing. Then you will have to set the right serial port as described before.

Now, you can run your Processing program. A new window will open and you should see something like this:

Output of the program

As you turn the potentiometer the vertical bar should move as it indicates the value read from the serial port.

Advertisements

Comments are closed.