Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
ddgold
Published © CC0

Controll Servo with Potentiometer

How to controll a Servo with Potentiometer!

IntermediateProtip1,287
Controll Servo with Potentiometer

Things used in this project

Hardware components

Rotary Potentiometer, 10 kohm
Rotary Potentiometer, 10 kohm
×1
Jumper wires (generic)
Jumper wires (generic)
×8
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1

Story

Read more

Schematics

Schematic

Code

code to controll servo with potentiometer

C/C++
copy paste or write it your self!
// eingebaute Bibliothek einbinden 
# include <Servo.h>

// Bezeichnung des Motors 
Servo Motor; 

// speichert den analogen Wert des Drehpotentiometers  
int ReglerWert; 

// Position des Motors 
int Position; 

void setup()  
{
  // Motor an Pin 9 angeschlossen (attach)
  Motor.attach(9); 
}

void loop()  
{
  int ReglerWert = analogRead(A0);   
  /*
    umwandeln des gelesenen Wertes in die Drehung des Motors 
    von 0 bis 1023 (analoger Sensorwert)
    auf 0 bis 180 (Drehung des Motors)
  */   
  Position = map(ReglerWert, 0, 1023, 0, 180);

  // Motor zur Position bewegen
  Motor.write(Position);
}

Credits

ddgold
0 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.