Output Devices

Output Devices

Moving a servo back and forth

The assignment of this week is to chose an output and make it do something. For my final project I want to work with servos so I though it'd be a good idea to test them in advance for this assignment. First, I tried to hack a 9g microservo and later on, control it with a selector made by me that is also a part of the final project.

Download the files here:
Code for servo [Arduino File]
For downloading Board and Schematic of Attiny44 board go to Final Project

The Process

  • For this assignment I am going to use a 9g microservo as my output device and I am working with the board of my final project that uses an Attiny44. This board has pins for other inputs and outputs but I will only pay attention to the ones for the servo and the selector (also part of the project)

  • Once I milled the board and added the necesary components to it (attiny44, 10k resistor, 1uf capacitor, 6pin header and pin headers for the servo), I tried to hack the board to convert it into a full rotation servo. For this, I followed this tutorial. It is important to know that some microservos are very difficult to hack due to the physical stop they have in one of its gears.. It would take to 3D print a new gear, but in my case that was impossible because our 3D printer do not print small objects in good resolution.

  • I succeded in hacking my microservo and started to work with it. First I tested with my arduino board and the "Sweep" example of the Arduino IDE.

  • However, when I moved to the Attiny44 board, I noticed it wasn't working the same way. I thought there was a bad connection or something was not soldered correctly, so I checked everything twice. It was not the problem. After reading a lot of blogs online, I found out that the new Servo.h library of Arduino IDE doesn't run on Attinys. I downloaded the old library and tested it. It worked fine.

  • Finally, I modified the "Sweep" example of the SoftwareServo.h library to respond to a digital input, that in my case was the selector (3 position switch) I made. It works well! When I activate the switch, the servo rotates in one direction and when I deactivate it it moves in the contrary directon. To see the servo working with the selector, watch the video above

Alejandra Díaz de León Lastras

Go back