# Cwik Clock v1.0 - An Arduino Binary Clock

## Step 6: Setting the Time With Potentiometers

We will be using potentiometers to set the time. The potentiometers will be used as variable resistors; the more you turn the knob, the more resistance the unit has.

If you're curious, a potientiometer works as a voltage divider. The reason why the resistance of the potentiometer is not necessary is because it's the only load between 5V and ground. Thus, on one extreme end of the knob you're connected directly to ground (0V), on the other extreme you're connected directly to 5V, and in between you'll get a smooth transistion from 0 to 5V. If you added some other load in series to one of the outside pins, then you'd need to carefully consider what resistance the potentiometer should be.

In order to set time using potentiometers, we'll hook up one outside lead to ground and the other outside lead to 5V, and measure the voltage from the middle lead using analogRead(). This will return a value between 0 (0V) and 1023 (5V). After that, it's just a matter of scaling the value to the number of hours (24) and minutes (60). We'll read the hours from pin A0, and the minutes from pin A1.

Behavior of Potentiometers (ie, Taper)
The relationship between the angle of the knob and the amount of resistance is known as the taper. Volume knobs often have a non-linear taper, where it requires more of a turn near the end to make a difference. Since all hour and minute values are equal, it seems logical to have a linear taper.

The Code
All that's needed is to set the m_inTimeSetMode to true for this step, and add the implementation for the getTimeFromPots() method to test out our time setting:

boolean m_inTimeSetMode = true;
int HOUR_INPUT_PIN = A0;
int MIN_INPUT_PIN = A1;

/**
* This method reads the values from the 2 potentiometers, converts them to
* minutes and hours, and sets m_minute and m_hour to the associated values.
*/
void getTimeFromPots()
{