top of page
Pot Controlled LED  Brightness Code

int potPin = 0;  //this is the analog pin that will read the varying signal coming from the potentiometer
int ledPin = 8;   // this is the pin that will send signal
int analogInputValue = 0;       // this is the number being read from the potentiometer (0-1023)

void setup() {
pinMode(ledPin, OUTPUT);  
// sets pin 8 as your output
Serial.begin(9600);
}

void loop() {
analogInputValue = analogRead(potPin);    
// reads the value coming from the potentiometer
int brightness = map(analogInputValue, 0, 1023, 0, 255);  //variable that maps the light values to 0-255 range
analogWrite(ledPin, brightness);  //Sends the “mapped” signal to the ledPin based on the analog value from the pot
}

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