## Plan

• Analog vs. digital
• Potentiometer
• Voltage dividers

## Analog vs. Digital  ## Analog vs. Digital

Analog Digital  infinite variations / states discrete (or finite) states

## Potentiometer (Pot) • Variable resistor with 3 pins
• power, ground, wiper

## Potentiometer (Pot) • Wiper pin connects to circuit
• As wiper moves, resistance varies from 0 Ohms to max (e.g. our kit has 10K Ohms pots)

## Where do we find pots? • Also car stereo knobs, dimming light switches, etc.

## How a Potentiometer Works ## How a Potentiometer Works • Vout is the wiper (middle pin; connects to Argon analog input)
• Inside the potentiometer is a resistor
• As the knob moves, the wiper divides the resistor, and the ratio of resistance between Vin-and-Wiper and Wiper-and-Gnd varies
• This is called a variable voltage divider (more on this later)

## Question • With a 10K Ohm pot, if the wiper is exactly halfway, what is the resistance between Vout and Gnd?

## Voltage Dividers • Argon input pins can measure voltage, not resistance
• By connecting Vin (3.3v), Gnd, and Vout (wiper), we can now vary the voltage difference Vin-and-Wiper and Wiper-and-Gnd

## Voltage Dividers • If the wiper is exactly halfway, what is the voltage between Vout and Gnd?
• If the wiper is all the way to the top, what is the voltage between Vout and Gnd?

## Voltage Divider

• As those resistances changes, so does the voltage difference between Vin-and-Vout and Vout-and-Gnd
• This is known as a voltage divider  Syntax

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

void setup() {
pinMode(PIN_POT, INPUT);
}

``````
• Technically, analog pins are input by default but I like to do this for clarity and consistency

Syntax

``````void loop() { 