In this lesson, we will add a potentiometer to our circuit. Make these connections for a slide potentiomter
[ ] GND on the potentiometer to ground on your breadboard
[ ] VCC on the potentiometer to positive voltage on your breadboard
[ ] OTB on the potentiometer to A0 on your microcontroller
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
int position;
int delaytime;
void loop()
{
delaytime = analogRead(0);
digitalWrite(position + 2, HIGH);
delay(delaytime);
delaytime = analogRead(0);
digitalWrite(position + 2, LOW);
delay(delaytime);
position = position + 1;
if (position > 3)
{
position = 0;
}
}