Devices & Components
Arduino Nano
Breadboard (generic)
Single Turn Potentiometer- 10k ohms
SG90 Micro-servo motor
Jumper wires (generic)
Project description
Code
Here is the code
arduino
1#include <Servo.h> 2 3 4 5 Servo servo_test; //initialize a servo object for the connected servo 6 7 int angle = 0; 8 int potentio = A0; // initialize the A0analog pin for potentiometer 9 10 11 void setup() 12 { 13 servo_test.attach(9); // attach the signal pin of servo to pin9 of arduino 14 } 15 16 void loop() 17 { 18 angle = analogRead(potentio); // reading the potentiometer value between 0 and 1023 19 angle = map(angle, 0, 1023, 0, 179); // scaling the potentiometer value to angle value for servo between 0 and 180) 20 servo_test.write(angle); //command to rotate the servo to the specified angle 21 delay(5); 22 } 23
Downloadable files
Here is the schematics
Here is the schematics

Here is the schematics
Here is the schematics

Comments
Only logged in users can leave comments