The Turkey’s Alive! – Sarah Anderson

For this project I decided to continue the holiday theme and do a piece about thanksgiving, which I am greatly looking forward to. For this piece I slaved all day to make this slightly overcooked turkey in a real metal pan, but when I press the giant red turkey timer button, IT COMES ALIVE!!! A servo in each leg kicks them back and forth for five seconds at random positions.

There are currently no pictures or videos since I still have not had a chance to fix the soldering and mechanical issues, but they will be up before break.

 

CODE

 

//Sarah Anderson, seanders
//EMS 2

#includeServo servo1, servo2;  
const int redButton = 11;
int prevCTime;
int period=5000;

void setup()
{
  pinMode(redButton, INPUT);
  servo1.attach(9);
  servo2.attach(10);
  prevCTime=0;
}

void loop()
{
  int redButtonState;
  redButtonState = digitalRead(redButton);
  int curTime= millis();
  int elapsed = curTime-prevCTime;

  if (redButtonState==LOW){ 
    prevCTime=curTime;

while (elapsed<period){
curTime= millis();
servo1.write(random(0,180));
servo2.write(random(0,180));
redButtonState = digitalRead(redButton);
delay(500);
elapsed = curTime-prevCTime;
}

}
}

(it would not let me put all the code together for some reason….)

Circuitry

 

Post a comment