Lab 8 — Servo Motors

J M
2 min readOct 31, 2021

--

Joanne Ma. Professor Kimiko Ryokai, Info C262, Fall 2021

Description

To understand rotational and linear motions, we were tasked with using a servor motor as an ouput to make an object crawl.

Materials

  • Arduino
  • Breadboard
  • Wires
  • Resistors
  • Potentiometer
  • Servo motor
  • Graph paper
  • Clothing tag
  • Masking tape

Part 1 — The Servo Motor

Control the Servo through Serial Monitor

I connected the servo motor to the Arduino so I could use the code provided by the lab to control the servo by inputting 1–9 on the serial monitor, which moves the sevor motor to corresponding positions betweeen 0 and 180 degrees.

I used blue tape to make it easier to tell whether the servo motor had spun. It was a helpful marker for troubleshooting when I was struggling to tell if my circuit had been built correctly.

Control the Servo with a Potentiometer

Next, I attached my potentiometer to the breadboard to control the servo motor position using a potentiometer, which acts as a variable resistor.

Part 2 — Make a Crawler

Homework

Leveraging the mechanism levers of the servo arms itself, I wanted to mix the grandeur of themed holiday floats with the end of October vibes to create a crawly, wobbly pumpkin. Before I embarked on creating an origami pumpkin as demo’d by Jo Nakashima, I tested out the crawler code using a frosted ghost.

/* Servo Sweep

just makes the servo sweep back and forth repeatedly

by BARRAGAN
This example code is in the public domain.

modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/

#include <Servo.h>

int servoPin = 7; // pin for the servo motor

Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

void setup() {
myservo.attach(servoPin); // attaches the servo on pin servoPin to the servo object
}

void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}

Realizing that the pumpkin would shift around without proper reinforcements, I taped the interior of the pumpkin stem and threaded the servo motor wires through the stem to help stabilize the pumpkin. I also constructed a “float” for the pumpkin to sit on to invoke more nearing winter break feels.

If I had more time, I would have liked to add more “organic” and erratic bug like crawls to my code to see how the pumpkin’s existing “legs” would fare. Overall, this was a super fun and doable lab despite the absolutely wild time in the semester.

--

--

J M

Grad student @ UC Berkeley’s School of Information. Interests include social computing, usable security, Being Online™️ and reflective tech.