Introduction: Potentiometer & Servo: Controlled Motion With Arduino

About: RISD MID 2021

First you need to gather relevant materials to put this circuit together.

Supplies

1 Arduino

1 Potentiometer

1 Servo

1 Breadboard

2 Black Jumper Wires (Ground/Negative)

2 Red Jumper Wires (Voltage/Positive)

2 Yellow/Color Jumper Wires (Input/Output)

Step 1: Understanding the Components

It is important before putting together the physical circuit to understand each component:

The breadboard has two sets of power rails on either side, that have slots for negative (black/blue) and positive (red) inputs. They are connected in series vertically. Terminal strips share the connection horizontally, however parallel terminal strips will require a jumper wire to bridge the divider.

The potentiometer has a 5V pin (red), a Vout pin (yellow/color) and Ground/GND pin (black).

The servo has a 5V port (red), a Pulse Width Modulation/PWM port (yellow/color) and a Ground/GND port (black). Click the link to know more about how it works.

Step 2: Setting Up the Circuit

Follow the diagram layout. While setting up the circuit, always remember to keep the arduino unplugged to avoid any damage to your components.

Plug the potentiometer into the breadboard, taking note of its orientation (this will be important when using the jumper wires to connect to the arduino). Use a yellow jumper wire and connect the middle output pin to the analog (A0) port on the arduino. Plug the red jumper wire into V5 port and a black jumper wire into GND port on the arduino.

Plug the servo into to the breadboard and arduino. Use a yellow jumper wire to connect it's input/signal port to the digital PWM port, 9 on the arduino. Plug the red jumper wire into V5 terminal strip and a black jumper wire into GND terminal strip in series with potentiometer layout (refer to image).

After the circuit is set up, proceed to connect your arduino into your computer.

Step 3: Download Arduino GUI and Input Code

Download Arduino Graphical User Interface (GUI) here.

Plug in the code below, note the information to the right of "//" tells you what that line of code is doing:

----copy below and paste into arduino GUI----

#include <Servo.h> //Servo library

Servo servo_test; //initialize a servo object for the connected servo

int angle = 0;

int potentio = A0; // initialize the A0analog pin for potentiometer

void setup() {

servo_test.attach(9); // attach the signal pin of servo to pin 9 of arduino

}

void loop() {

angle = analogRead(potentio); // reading the potentiometer value between 0 and 1023

angle = map(angle, 0, 1023, 0, 179); // scaling the potentiometer value to angle value for servo between 0 and 180)

servo_test.write(angle); //command to rotate the servo to the specified angle delay(5);

}

Step 4: Potentiometer + Servo + Arduino

This is how the final circuit should look. Watch the video to see how it works.