My third milestone is finishing the code for the other two servos and building the lamp.
In this milestone, I added a capacitor, a common ground, a new way of moving servos, and some more commands for the lamp. For the servos, I move them using for loops now, one degree at a time, with a delay between each degree. This way, the servos move much slower, so there is a smaller chance of the lamp breaking. Some commands I added were down, up, and lumos (Harry Potter spell!).
Although setting up the lamp and coding the other two servos should be relatively simple, I encountered many challenges in the process. My first challenge had to do with the servos buzzing. The servos wouldn’t move, and would start to buzz louder and louder. What solved this was putting a capacitor and a common ground in my circuit. I needed a capacitor because the servos were drawing spikes in the current, so the capacitor was there to stabilize the voltage. The common ground is an imperative part of the circuit as voltage is only relative, and needs to be compared to a zero level or ground.
Another problem was with the 3d printed materials. While I was testing, the part connecting the base servo and the rest of the lamp snapped, so the bottom servo was rendered useless. I had to rebuild another lamp, meaning that I had to wait for materials, or think of a better idea. What I eventually did was replace the old servo, add a servo horn to the new one, and glue it along with a wooden block to the rest of the lamp. I also wanted to make sure that the same thing doesn’t happen again. I had a few options: build a support for the part, or to use the middle arm less. I decided to do the latter due to a lack of time. I also tried to make sure that the lamp always kept its center of mass in the same place. I did this by moving the middle arm by one degree every five degrees the top arm moves.
My code for this milestone will be on my github.