This week, I decided to use the potentiometer as a toggle between 3 different lights which represent “yes” “no” or “maybe”.

I then took the wired up Arduino outside to ask 3 people 5 questions and they answered using LED lights.

 

 

Below is the code:

#define ledblue 12
#define ledwhite 13
#define ledred 8
#define potPin A0
int sensorValue = 0;
void setup() {
pinMode( ledblue, OUTPUT );
pinMode( ledwhite, OUTPUT );
pinMode( ledred, OUTPUT );
pinMode( potPin, INPUT );

}

void loop() {
sensorValue = analogRead (potPin);

if (sensorValue >=0 && sensorValue <=100)
{
digitalWrite (ledblue, LOW);
digitalWrite (ledwhite, LOW);
digitalWrite (ledred, HIGH);
}
if (sensorValue >100 && sensorValue <200)
{
digitalWrite (ledblue, LOW);
digitalWrite (ledwhite, HIGH);
digitalWrite (ledred, LOW);
}

if (sensorValue >=200)
{
digitalWrite (ledblue, HIGH);
digitalWrite (ledwhite, LOW);
digitalWrite (ledred, LOW);
}
}