For this week’s assignment, we need to imitate a human gesture with servo motors. The first thing that comes to my mind is the motion that involves hands. At that time I could not find more motors, so I just used the one in my kit. The whole idea is to make a baseball foam cardboard finger that swings from left to right and comes back to the initial position.
So I cut out from the cardboard the shape of a foam finger, slightly decorated it, and attached a stick on its back, which is taped to the servo’s spinning wing. Then I simply connected the servo to the breadboard, and added a switch to control the motion. I slightly adjusted the angle of the swinging motion so that the finger does not point directly downwards, which is depressing instead of cheering in a baseball game. Here’s a super short video about how it works:
The code looks like this:
#include <Servo.h>
Servo myServo;
int angle = 0;
void setup() {
// put your setup code here, to run once:
myServo.attach(9);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(10) == HIGH) {
for(angle = 0; angle <= 120; angle += 3){
myServo.write(angle);
delay(20);
}
for(angle = 120; angle >= 0; angle -= 3){
myServo.write(angle);
delay(20);
}
}
}
The thing is, the finger needs to be more colourful itself, and the motion involved should be more complicated and fun. I probably would add a pulse sensor to control the frequency of the swinging motor, or add another motor to add a pointing-forward gesture on the forefinger.