Memory Button for Potentiometer Servo Setup on Arduino: Motion Memory Loop

Introduction: Memory Button for Potentiometer Servo Setup on Arduino: Motion Memory Loop

About: RISD MID 2021

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


1 Arduino Uno

1 Potentiometer

1 Servo

1 Breadboard


1 Push button

2 Resistors (330 Ohm)

3 Black Jumper Wires (Ground/Negative)

4 Red Jumper Wires (Voltage/Positive)

4 Yellow/Color Jumper Wires (Input/Output)

Step 1: Understanding the Components

It is important before putting together the physical circuit to understand each component (new informational links to 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.

A resistor is a passive two-terminal electrical component that implements electrical resistance as a circuit element. Resistors are used to provide biasing voltages that control the gain of amplifiers, they are used to limit currents to safe levels and prevent overheating, they provide a way to sense current and voltage for circuit control and more.

The LED is short for Light Emitting Diode. The longer leg or anode side connects to the positive and the shorter leg or flat side of the LED, cathode connects to the Ground/GND. In this set up we require a resistor, which will also be used in the connection to the ground.

The Push Button has a left and right side, when the button is clicked it finishes the circuit. One side will connect to the 5V or positive, and the other will connect to the ground (through the resistor) and pwm pin on the arduino.

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.

Connect the Arduino: 5V with a red jumper wire to the terminal strip on the bread board the "+" or anode side; connect the Ground/GND with a black jumper wire to the terminal strip on the bread board with the "-" or cathode side.

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, 7 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).

Connect the LED into the breadboard, remember which is "+" (longer leg) and what is "-" (flat side of LED). Connect the push button, and resistor for each component. The resistors will connect the cathode rise to the ground. The pushbutton connects to PWM 2 pin, and LED to PWM 3 pin.

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 servo1; // testing for a single potentiometer & servo combination

int AnalogOut = 0;

int NewAnalogOut = 0;

int pin_Button = 2; //attach button to PWM pin 13

int ledPin = 3; //status LED when push button is on

int pin_Button_State = 0;

int pin_Button_State_Last = 0;

int storage[200]; // # of positions for recording

int storage_loc = 0;

int recording = 0;

void setup() {

Serial.begin(9600); //turn on serial monitor

servo1.attach(7); //attach servo to PWM pin 7

pinMode(pin_Button, INPUT); //button for playback

pinMode(ledPin, OUTPUT); //LED is an output


void loop() {

if (recording == 0) { //not recording state

int sensorValue = analogRead(A0); //reading potentiometer at analog pin A0

NewAnalogOut = map(sensorValue, 0, 1023, 80, 0); //only has 80 degrees of rotation translated

if (abs(NewAnalogOut - AnalogOut) > 2) { //abs is for absolute, recording speed with value

AnalogOut = NewAnalogOut;





if ( recording == 1) { //recording turned on

digitalWrite(ledPin, HIGH); //turn on LED, to signify recording

recording = 1;

if (storage_loc < 200) {

int sensorValue = analogRead(A0);

NewAnalogOut = map(sensorValue, 0, 1023, 80, 0);

storage[storage_loc] = NewAnalogOut;






} else if (recording > 1) { //recording playback, hit reset on arduino to stop playback

storage_loc = 0;

digitalWrite(ledPin, LOW);

while (1 == 1) {

if (storage_loc < 200 and storage[storage_loc] != 666) {


storage_loc ++;






storage_loc = 0;




pin_Button_State = digitalRead(pin_Button);

if (pin_Button_State != pin_Button_State_Last) {

if (pin_Button_State == HIGH) {


if (recording == 2) {

storage[storage_loc] = 666;



delay(50); //number of "frames" or speed it is recording at, due to number of delays in the loop


pin_Button_State_Last = pin_Button_State;


Step 4: Push Button + LED + Potentiometer + Servo + Arduino

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

Be the First to Share


    • Maps Challenge

      Maps Challenge
    • DIY Summer Camp Contest

      DIY Summer Camp Contest
    • Summer Fun: Student Design Challenge

      Summer Fun: Student Design Challenge