HotPot Rotary Potentiometer

Last updated: 8 October 2012
Prepared by Marco De Mutiis [marcodemutiis@gmail.com]
URL: https://www.sparkfun.com/products/9074?
Cost per unit: $18.95USD (approx. 150 HKD)
hotpot.png


General Information

HotPot Rotary Potentiometer

The HotPot is the preferred product for industrial and outdoor applications. By pressing down on various parts of the rotary dial, the resistance linearly changes from 100Ohms to 10,000Ohms allowing the user to very accurately calculate the relative position on the rotary. Can be used as an accurate positional indicator for rotational items, variable user input (volume level input for example), straight user input (multiple button areas translate to given resistance levels), and many other applications.
(excerpted from sparkfun product description, accessed 8 October 2012).
hotpotbent.png
Features & Specifications

- Diameter : 46mm (1.811")
- Resistance: 10 kOhm
- Resistance Tolerance: ?20%
- Linear Tolerance: ?3%
-Temp Range: -40?C to +85?C standard




Getting it to work!
Connection
hotpotconnect.png
PIN1 of the HotPot Rotary connected to 5V pin on Arduino
PIN3 of the HotPot Rotary connected to GND pin on Arduino
PIN2 of the HotPot Rotary connected to Any digital input pin (example uses 5)
hotpotschematics.jpg

Example Code


The following example sends data coming through the AnalogIn from the HotPot Rotary Potentiometer to the Serial Port. In Processing the values sent by the Arduino are transformed in sinewaves and waveforms are visualized.

Arduino Code
see comments for explanation

the HotPot Rotary Potentiometer is connected to analog pin 5
const int HotPotPin = A5;
variable to store the value read from the sensor pin
int sensorReading = 0;

void setup() {
Serial.begin(9600); use the serial port
}

void loop() {
read the sensor and store it in the variable sensorReading:
sensorReading = analogRead(HotPotPin);
write the sensor's data to the Serial Port (AnalogIn data range is 0-1023, so we divide it by 4 to have a closer range for digital data range 0-255)
Serial.write(sensorReading/4);
delay to avoid overloading the serial port buffer
delay(100);
}





Processing Code
import ddf.minim.*;
import ddf.minim.signals.*;
import processing.serial.*;

Serial myPort; Create object from Serial class
Minim minim;
AudioOutput out;
SineWave sine1;

int val; Data received from the serial port
float amp1 = 0.8;
float sr = 44100;

void setup()
{
size(512, 200, P2D);
I know that the first port in the serial list on my mac
is always my FTDI adaptor, so I open Serial.list()[0].
On Windows machines, this generally opens COM1.
Open whatever port is the one you're using.
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600);
minim library settings to create a line out and a sine wave
minim = new Minim(this);
out = minim.getLineOut(Minim.STEREO, 2048);
sine1 = new SineWave(val, amp1, sr);
out.addSignal(sine1);
}

void draw()
{
background(0);
stroke(255);

if ( myPort.available() > 0) { If data is available,
val = myPort.read(); read it and store it in val
println(val); prints the sensor data to the console
}

create visualization of waveforms
for (int i = 0; i < out.bufferSize()-1; i++)
{
float x1 = map(i, 0, out.bufferSize(), 0, width);
float x2 = map(i+1, 0, out.bufferSize(), 0, width);
line(x1, 50 + out.left.get(i)*50, x2, 50 + out.left.get(i+1)*50);
line(x1, 150 + out.right.get(i)*50, x2, 150 + out.right.get(i+1)*50);
}
sine1.setFreq(val*2); //set the frequency to the sensor data times 2 (so we get higher frequency)
}

voidstop()
{
out.close();
minim.stop();
super.stop();
}