For this project, I made a few test programs before putting together the final code. I designed one program which tested the flex sensor, which only used one analog pin. The idea in testing the individual sensors on their own was so that it would be easier to understand what kinds of data would come out, depending on different states. For example, I wanted to know what analog values I could get from both bending and keeping the resistive flex sensor straight. Next, I wrote a program to test the servo library and ensure my servos would work properly. To do this, I had to define a digital pin for the servo and instantiate a servo object. Then, I used the servo object and called the function write() to tell it how far to rotate. I could use any value between 0 and 180, since it is defined in degrees. This program helped me immensely for making sure my servos worked and for when I had to put together the entire build. Finally, I wrote a program to get the inputs from both the flex and motion sensor. I used a MPU6050 library to assist me in obtaining the best data from the motion sensor. After I used this code, I put in the flex sensor code from my other program in it. After this, I wrote my final program to place in the conditional checks for the flex and motion sensors. These would check the values of my input sensors to see if and where the servos should move. This project was interesting since I had to dynamically turn the servos based on a ratio of the analog values I was receiving, which was unique from my previous digital project where I was processing the sound LED’s as either on or off.
Finally, I was able to assemble the 3D printed parts and individual electronic components I had tested into one full piece. I had some trouble assembling the pieces with the holes for the servos to go in that I 3D printed. So, to fix this, I ended up putting the plastic teeth that come with the servos and then hot gluing the parts together. I didn't enjoy this solution, since it made it more difficult to take the arm apart in the future. I ended up investigating a better way to implement the servo attachments, which can be seen in the “useless” machine that I created in my Sophomore year of school. The code ended up working very smoothly on the first few runs. I started the final code by testing one servo joint at a time. I did this so I could make sure each individual servo was working correctly, and so that they wouldn't all break at once and damage the arm. At this point the project was pretty much done and now I had an extra robot hand to help me do whatever I needed!