# Analog to Digital Conversion

# Analog to Digital Conversion

## Analog vs. Digital

- Analog:
**infinite** variations / states
- Digital:
**discrete** (or **finite**) states
- How do we represent infinite variations in a system that has limited / finite values?

## Analog to Digital Conversion

- Argon is a digital system so we need to convert the infinite analog input to a discrete values
- At regular intervals, the Argon
**samples** (“reads”) voltage on analog input pin it sees
- The
**sampling frequency** is how many times per second

- The
**resolution** is how many bits are used to store the voltage
- Higher resolution means greater detail, but also more bits (more memory)

## Understanding Resolution

- Red line is actual analog input voltage (in volts)
- Blue line is the digital sample value (just a number with no units)

## Argon ADC Resolution is 12-bits

- When we read the analog input voltage, ADC converts the voltage to a number
- There 2^12=4096 possible values (think “buckets”)
- In Binary
- 0 = 000000000000
- 4095 = 111111111111

## Argon ADC

- The range of analog voltage is 0v to 3.3v
- The range of digital values is 0 to 4095
- Q: How many digital values per 1v?
- Q: How many volts per each digital value?
- Q: If there is 3.3v on an analog input, what is the value of
`analogRead()`

?
- Q: If there is 1.67v on an analog input, what is the value of
`analogRead()`

?

## Exercise

- Connect potentiometer to analog pin A0
- Connect LED to digital pin D2 (do we a pin with PWM?)
- Control LED brightness with potentiometer

## Credit