Arduino Beginner Series: Project 4: Dimmable LED

Hello everyone!! Welcome to this post on Arduino Projects!!
Need a short introduction to what the Arduino is then click on LINK
Check out the breadboard intro right HERE

So in this project we’ll make a LED brightness controller using a potentiometer (variable resistance)

Demo:

So this is what my project looks like:

Things Required:

  1. Arduino UNO
  2. USB AB cable
  3. LED (any color)
  4. 10 k ohm resistor
  5. Breadboard
  6. 220 ohm resistor
  7. Arduino IDE on computer
  8. jumper wires

Important Concepts:

  1. Understanding how a potentiometer works: (LINK)
  2. Setting up circuit: (LINK)

Functions used:

  1. analogRead()
  2. pinMode()
  3. analogWrite()

Code:

int pot_val;
float led_val;
int led_pin=9;
int pot_pin=A0;

void setup() {
  // put your setup code here, to run once:
  pinMode(pot_pin, INPUT);
  pinMode(led_pin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  pot_val= analogRead(pot_pin);
  led_val= (255.0/1023.0)*pot_val;
  analogWrite(led_pin, led_val);

}

Stay Tuned for upcoming posts on Arduino Projects! We’re on the basic newbie projects right now and slowly, gradually move on to those cool, ultra techy projects!! Want to be the first to know when a new and amazing post comes up?? Then feel free to subscribe!

Happy Learning!!

Leave a Reply

PHP JS HTML CSS BASH PYTHON CODE

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close