When you squeeze the gorillas hand, he responds by shaking hands with you. The Handshake Gorilla is a design for beginner level Arduino workshops. FabLab Manchester asked me to give a workshop on making interactive products with Arduino, so I thought it would be nice with a playful design.
The design features a simple touch sensor, a servo powered arm and a gorilla puppet. The gorilla can be cut out by hand or with a laser cutter. The design is suitable for expanding with more advanced sensors and new animal shapes.
Here is the arduino code:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
const int triggerCable = 2; // the cinnection port (digital in this case) for the trigger cable
int triggerState = 0; // variable for reading the status of the trigger cables (connected or not)
int armUp = 90; //rotation degree of the servo when the arm is up
int armMid = 45; //standard position for when the arm is moving
int armDown = 0; //rotation degree of the servo when the arm is down
int armPause = 800; //the time we allow the servo to rech the instructed position
void setup() {
pinMode(triggerCable, INPUT); // initialize the trigger cable pin as an input:
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop(){
// read the state of the trigger cable value:
triggerState = digitalRead(triggerCable);
// check if the pushbutton is pressed.
// if it is, the triggerState is HIGH:
if (triggerState == HIGH) {
// turn LED on:
myservo.write(armDown); // tell servo to go to armDown position
delay(armPause); // tells the program to wait as longs as specified in “armPause”, gives the servo time to reach the defined position
myservo.write(armUp); // tell servo to go to armUp position
delay(armPause); // tells the program to wait as longs as specified in “armPause”, gives the servo time to reach the defined position
}
else {
// turn LED off:
myservo.write(armMid); // tell servo to go to armMid position
}
}
Leave a Comment