Initially, I wanted to create a slapping machine that would wack us across the face with a palm shaped cardboard cut out. But then, that kind of seemed too dark so I opted to make a leg that would simulate the kicking motion.
I used a few pieces of acrylic that were cut into rectangles to form the actual leg and I implemented a standard servo motor to generate the motion. The motion was triggered by a button. To finish things off, I added some lovely decorations that would bring the device to life.
My code:
#include <Servo.h>
Servo myServo;
const int servoPin = 5;
const int buttonPin = 3;
bool buttonState = LOW;
bool prevButtonState;
void setup() {
// put your setup code here, to run once:
pinMode(buttonPin, INPUT);
myServo.attach(servoPin);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
buttonState = digitalRead(buttonPin);
Serial.print(buttonState);
if (buttonState == HIGH && prevButtonState == LOW){
myServo.write(30);
delay(500);
myServo.write(160);
delay(100);
}
prevButtonState = buttonState;
}
Device Demo: