(Reference) Potentiometers

Potentiometers

Potentiometer (Pot)

potentiometers

Wiring

  • Requires analog input pin (Pins A0-A5)

Operation

  • As you turn the knob, Argon will measure a voltage change on analog input (due to voltage divider)
  • Since this is an analog input, we use analog to digital conversion to read input
  • Voltage on pin will varies 0v to 3.v, and Argon will read 0 to 4095

Code

const int PIN_POT = A0;		//input pin
int potValue = 0;			//value from read

void setup() {
    pinMode(PIN_POT, INPUT);
}
void loop() {
   	// read analog value (ADC); range 0-4095
    int potValue = analogRead(PIN_POT);
    
    // if you want to know the actual voltage 
	int voltage = (float) lightReading / 4095 * 3.3;
}

Credit

Updated: