Team:
Christina Yee, Cesar Torres, Jordan Arnesen, Tim Campbell, Clemens Meyer
Description:
In this project, we explored simple mechanics and the interplay and timing of a pair of servo motors. We wanted to give the cuckoo clock concept a new twist. In anticipation of the Thanksgiving holidays, we chose to display the assassination of a turkey. The turkey opens the door and looks outside, just to be hit by an axe from above a moment later.
Video: https://www.dropbox.com/s/x344v3o6lyziggn/Barn_Turkey.MOV
Components used:
- (1) Arduino
- (1) Bread board
- (2) Servo motors
- (6) Cables
- Laser-cut plastic
- Modeling foam
- Several screws as joints
- Cardboard
- Hot glue
Code:
/*
* Turkey Assassin
* By Christina Yee, Cesar Torres, Clemens Meyer, Jordan Arnesen, Tim Campbell
*
* In this project, we explored simple mechanics and the interplay
* and timing of a pair of servo motors. We wanted to give the cuckoo
* clock concept a new twist. In anticipation of the Thanksgiving holidays,
* we chose to display the assassination of a turkey. The turkey opens the
* door and looks outside, just to be hit by an axe from above a moment later.
*/
#include <Servo.h> // Using Arduino's built-in servo library
Servo turkey;
Servo axe;
// Set pins of turkey and axe servos
int turkeyPin = 7;
int axePin = 8;
// Set angles for turkey and axe servos (in degrees)
int turkeyIn = 90;
int turkeyOut = 40;
int turkeyMiddle = (turkeyOut+turkeyIn)/2;
int axeUp = 0;
int axeDown = 120;
int axeMiddle = (axeUp+axeDown)/2;
void setup() {
// Initialize servos
turkey.attach(turkeyPin);
axe.attach(axePin);
// Initialize serial connection
Serial.begin(9600);
Serial.println("Let the turkey killing begin!");
// Set servos to middle position, then slowly to initial positions to avoid damage to the machine
turkey.write(turkeyMiddle);
servoSteps(turkey, turkeyMiddle, turkeyIn, 4, 50);
axe.write(axeMiddle);
servoSteps(axe, axeMiddle, axeUp, 4, 50);
}
void loop() {
runTurkeyLoop();
}
void runTurkeyLoop() {
Serial.println("Moving turkey out slowly.");
servoSteps(turkey, turkeyIn, turkeyOut, 2, 50);
delay(500);
Serial.println("Moving axe down quicky.");
axe.write(axeDown);
delay(2000);
Serial.println("Moving axe up slowly");
servoSteps(axe, axeDown, axeUp, 1, 50);
delay(500);
Serial.println("Moving turkey in slowly");
servoSteps(turkey, turkeyOut, turkeyIn, 2, 50);
delay(500);
}
// Function to go in small steps from one servo position to another
void servoSteps (Servo myservo, int beginning, int ending, int stepsize, int waiting) {
// If start value is lower then end value, increment value by stepsize until end value is reached
if(beginning<ending) {
for (int i=beginning; i<ending; i+=stepsize) {
myservo.write(i);
Serial.println(i);
delay(waiting);
}
}
// If start value is higher then end value, decrease value by stepsize until end value is reached
else {
for (int i=beginning; i>ending; i-=stepsize) {
myservo.write(i);
Serial.println(i);
delay(waiting);
}
}
}
- Login to post comments