Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Super Kid
Published © GPL3+

Break Your Heart - Arduino PWM (Control an LED)

A #Breakyourheart tag for controlling an LED by the potentiometer.

BeginnerShowcase (no instructions)945
Break Your Heart - Arduino PWM (Control an LED)

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Microsoft Windows 10 PC
×1
Breadboard (generic)
Breadboard (generic)
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
LED (generic)
LED (generic)
×1
Resistor
×2
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Sample Code

Arduino
int led = 6;
int potentiometer = 5;
int brightness;
int fadeAmount;
void setup() {
  // put your setup code here, to run once:
pinMode(led, OUTPUT);
pinMode(potentiometer, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
analogWrite(led, brightness);
brightness = analogRead(potentiometer) + fadeAmount;
if(brightness == 0 || brightness == 255);
{
  fadeAmount = -fadeAmount;
}
}

Credits

Super Kid
1 project • 27 followers
I am building the project with IoT with Windows (Windows On Devices). Also I have a tag: Break your heart for the beginner.
Contact

Comments

Please log in or sign up to comment.