MisterBotBreak
Published

How to Use a Potentiometer

This project will show you how to use a potentiometer (with an LED).

BeginnerProtip1 hour2,752
How to Use a Potentiometer

Things used in this project

Hardware components

Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Arduino UNO
Arduino UNO
×1
LED (generic)
LED (generic)
×1
Resistor 10k ohm
Resistor 10k ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Connections potentiometer del

Connection potentiometer servo

Code

Code potentiometer LED

Arduino
This code will blink more or less quickly based on the position of the cursor.
int led=13;
int t;

void setup ()
{
  pinMode(led,OUTPUT); 
}

void loop()
{
  t = analogRead(A0);
  digitalWrite(led, HIGH);
  delay(t);
  digitalWrite(led, LOW);
  delay(temps);
}

Code potentiometer servo

Arduino
#include <Servo.h>
 
Servo monServo;  
 
const char AN_POTENTIOMETRE = 0;  
const char PWM_SERVO = 9;   
int positionDuServo = 0;
 
void setup()
{
  monServo.attach(9);  
}
 
void loop()
{
  positionDuServo = analogRead(AN_POTENTIOMETRE);           
  positionDuServo = map(positionDuServo, 0, 1023, 0, 180);     
  monServo.write(positionDuServo);              
  delay(15);                          
}

Credits

MisterBotBreak
48 projects • 152 followers
I love electronics and cats :D !
Contact

Comments

Please log in or sign up to comment.