Connecting a potentiometer to the arduino, analog in
October 30, 2007 — hcgilje(sketch based on illustrations in the books “Physical Computing” and “Making things talk”.)
Here is a simple arduino code example illustrating both Analog in and out:
int potVar = 0;
void setup() {
Serial.begin(9600);
pinMode(11, OUTPUT);
}
void loop() {
//read the voltage on the potentiometer:
potVar = analogRead(0);
//print the value out:
Serial.println(potVar, DEC);
//slight pause
delay(10);
//dim the LED. since the resolution of the input is 10bit and the output(1024)
//is only 8bit (255) we need to divide potVar by 4 to get the right range
analogWrite(11,potVar/4);


October 30, 2007 at 10:19 pm
[...] Connecting a potentiometer to the arduino, analog in [...]