Tarantula3DIYables
Published © GPL3+

LED Fader - With or Without Arduino

How to fade a LED with or without an Arduino automatically or manually using a potentiometer.

BeginnerProtip1 hour2,320
LED Fader - With or Without Arduino

Things used in this project

Story

Read more

Schematics

arduino_fade_DudYLcRZIo.zip

Code

Arduino_Fade_Using_Potentiometer.ino

Arduino
int LedPin = 9;               // Digital pin the LED is attached to
int Pot    = A0;              // Potentiometer is connected to A0
int Knob   = 0;               // Value of the Potentiometer

// The setup routine runs once when you press reset
void setup() {
  pinMode(LedPin, OUTPUT);    // Declare pin 6 to be the output pin
}

// The loop routine runs over and over again forever
void loop() {
  Knob = analogRead(Pot);     // Reading the value of the Potentiometer
  Knob = map(Knob, 1, 1024, 1, 255); // Mapping variable 'Knob' to a range between 1 to 255

  analogWrite(LedPin, Knob);  // Send the value of 'Knob' to the LED
}

Credits

Tarantula3

Tarantula3

62 projects • 82 followers
There were 1000+ sperms but I was the fastest one..
DIYables

DIYables

0 projects • 64 followers
I would like to invite you to join and add your projects to DIYables platform https://www.hackster.io/diyables

Comments