The hand design was only half of the responsibilities for the project. I wrote, with the help and input from my group mates, the code for the logic of the game. The hand runs on an Arduino MEGA. All of the score tracking, servo control, stepper motor control, and visual aids all ran off of this microcontroller. I decided that this was the microcontroller of choice because it has enough digital pins to run an LCD, some LEDs, and was capable of sending at least six PWM signal for all six servos in the hand. The only input to the Arduino was serial communication from a Raspberry Pi running Python. My group-mate programmed the Pi to track when to start the game by the motion/gesture of the player. To simplify the commands, all messages were defined as a single number so message lengths would be short and simple.
I started coding the hand by programming it to loop between all the hand gestures. Originally this was going to be done by telling the servos an angle of rotation, but to get the most range out of the servos (degrees), I decided on ones that had 360 degrees of continuous rotation. Basically, the servos were just small DC motors with attached gearboxes and a LAP driver. The first round of programming was all open loop, but the timing was going to be an issue. This ended up being a good start to see that the mechanics of the hand worked, but showed that there were more electronics needed.
The next step was making all the motor controls run on a closed loop by adding a sensor to track the positions of the servos. I went with photogates to track a slit I was going to add on the servo wheels. After making said slit, I learned that the orange PLA I was using is somewhat transparent to infrared. At this point, I had already finished the design for the arm with all the photogates. As a solution, I ended up painting a black section on the wheels to break the infrared beam so that the photogates would still work. In hindsight, a bump switch might have been an easier solution, or using a comparator for the photogates to get more accurate and settable reading . There was a small issue of the photo games sometimes not getting triggered if there was too much fluorescent light, so in the code, if a loop counts for just under a second, checking if the beam is broken and if it never detects it, it will stop the servos after the preset time. This works very well to control the servo position. Occasionally, they might overshoot their position a little, but this is corrected during the next movement.
All of the different hand gestures and score tracking are separate functions that can be called when needed. This simplified the game logic to simple call functions. In all, the programming of the hand was a great learning experience.
Code via Github: https://github.com/Engineermanx2/RPSrobot