Experiment #7: Basic servo test

At least some of the diorama's electo-mechanical "features" will be operated by servo motors. Several SG90 9G servo motors have been obtained.

This experiment was aimed at learning the basics of how such motors are operated using the Arduino Servo library and to check performance of a servo motor against expectations.

A simple circuit was created that used an Arduino Uno clone to control a single servo. Connections were as follows:

Uno Pin Servo Connection Notes
5V VCC 5V Power supply
GND GND Ground connection
8 SIG PWM control signal

The Uno was programmed put the servo through its paces. It first moves the servo to pre-determined angles and then sweeps the servo's arm from its minimum to maximum angles and back again. After a pause the whole process is repeated.

The program is modified from "Sweep" by Damian Barragan, as modified by Scott Fitzgerald. This version is released into the public domain, under the CC0 (public domain) license.

The source code is available from the cahamo/diorama repository on GitHub. The relevant code will be found in the research/feature-tests/basic-servo-test/src directory. All the C++ code is in basic-servo-test.cpp.

This program was developed using VSCode using the PlatformIO extension. It can be modified for use with the Arduino IDE simply by copying the code into a new, blank project. The required Servo library is installed in the Arduino IDE by default.

The program was run and the behaviour of the servo was observed and found to match the expected performance.

Back to Main project page