
Pot Controlled LED Code
​int potPin = 0; // This names the analog pin that will read the varying voltage signal from the potentiometer.
int ledPin = 8; // Names the pin where the signal will be sent to the led.
int analogInputValue = 0; // Names a placeholder for the value 0-1023 that will be read from the potentiometer.
void setup ( ) {
pinMode (ledPin, OUTPUT); // Sets pin 8 as an output.
}
void loop ( ) {
analogInputValue = analogRead (potPin); // Reads the value returned from the potentiometer.
digitalWrite (ledPin, HIGH); //Turns the LED on.
delay (analogInputValue); // Leaves the LED on for the input’s value from the pot in milliseconds.
digitalWrite (ledPin, LOW); //Turns the LED off.
delay (analogInputValue); // Leaves the LED off for the input’s value from the pot in milliseconds.
}