Using a potentiometer and one of the Arduino’s analog-to-digital conversion (ADC)
pins it is possible to read analog values from 0-1024. The following example uses a
potentiometer to control an LED’s rate of blinking.

int potPin = 0; // input pin for the potentiometer
int ledPin = 13; // output pin for the LED
void setup()
{
 pinMode(ledPin, OUTPUT); // declare ledPin as OUTPUT
}
void loop()
{
 digitalWrite(ledPin, HIGH); // turns ledPin on
 delay(analogRead(potPin)); // pause program
 digitalWrite(ledPin, LOW); // turns ledPin off
 delay(analogRead(potPin)); // pause program
}
Author

Write A Comment