Will_the_Star
Published © GPL3+

Tutorial for Arduino Beginners PART II

Using a potentiometer to control an LED light.

BeginnerFull instructions provided848
Tutorial for Arduino Beginners PART II

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
5 mm LED: Red
5 mm LED: Red
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Computer

Story

Read more

Schematics

The Finished Project

All Done

Code

LED with Potentiometer

C/C++
Paste it into the IDE window and hit upload
int analogPin = A0;
int analogPin2 = A1;
                       
int val = 0;
int val2 = 0;           

void setup()
{
  Serial.begin(9600);              
}

void loop()
{
  val = analogRead(analogPin);
  val2 = analogRead(analogPin2);     
  Serial.println(val);   
  analogWrite(analogPin2, val * 0.2)     
;}

Credits

Will_the_Star

Will_the_Star

6 projects • 26 followers
I am eleven years old. I have a proven IQ of 154. I am not lying, joking, kidding or trying to mislead you in any other way.

Comments