top of page
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.
}

Igniting Innovation through Functional Prototyping and Physical Computing

Contact Information

odysseyboardedu.@gmail.com
Phone: (360) 303-5526
24338 Lee Road
Mount Vernon, WA 98274

Contact Us

Thanks for submitting!

© 2017 by Odyssey Board. All rights reserved.

bottom of page