Arduino - Servo Motor Controlled By Potentiometer
Maybe your like
Arduino Code
/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-servo-motor-controlled-by-potentiometer */ #include <Servo.h> Servo myServo; // create servo object to control a servo void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); myServo.attach(9); // attaches the servo on pin 9 to the servo object } void loop() { // reads the value of the potentiometer (value between 0 and 1023) int analogValue = analogRead(A0); // scales it to use it with the servo (value between 0 and 180) int angle = map(analogValue, 0, 1023, 0, 180); // sets the servo position according to the scaled value myServo.write(angle); // print out the value Serial.print("Analog: "); Serial.print(analogValue); Serial.print(", Angle: "); Serial.println(angle); delay(100); }Quick Steps
- Connect Arduino to PC via USB cable
- Open Arduino IDE, select the right board and port
- Copy the above code and open with Arduino IDE
- Click Upload button on Arduino IDE to upload code to Arduino
- Open Serial Monitor
- Rotate the potentiometer
- See the servo motor's rotation
- See the result on Serial Monitor
Code Explanation
Read the line-by-line explanation in comment lines of source code!
Tag » Arduino Sg90 Potentiometer
-
Servo Motor Control With Potentiometer - Arduino Project Hub
-
Control Servomotor Using Potentiometer & Arduino Uno
-
Control Servo Motor With Arduino Uno And POT
-
Arduino : How To Control Servo Motor With Potentiometer
-
Arduino Tutorial: Servo Potentiometer Control - Beginner Project
-
Arduino Servo Motor Control With Potentiometer - YouTube
-
How To Control Servo Motor By Potentiometer | Arduino | TinkerCad
-
Lesson 85: Control Servo Motor With Potentiometer Using Arduino
-
8. Project 1: Control a Servo Motor With A Potentiometer
-
How To Control Servos With The Arduino - Circuit Basics
-
Arduino Potentiometer Controlled Arm - Sutori
-
Servo Motor Control With An Arduino - Projects - All About Circuits
-
Controlling Servo Motor With A Potentiometer!