Inspired by all this skeleton building, when a servo arrived in the post, a friend and I couldn’t resist bolting it to the cardboard skull, from skeleton #1.
Then when I acquired a broken angle-poise table lamp I saw great potential…
See the short video here: Skull Video
Here is the arduino sketch :
#include <Servo.h>
#include <Bounce.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
#define PIN_SWITCH 2
#define PIN_SERVO_CONTROL 9
#define PIN_LEFT_EYE 6
#define PIN_RIGHT_EYE 11
#define DEBOUNCE_MILLISECS 5
// Instantiate a Bounce object with a 5 millisecond debounce time
Bounce bouncer = Bounce( PIN_SWITCH ,DEBOUNCE_MILLISECS );
void setup()
{
myservo.attach(PIN_SERVO_CONTROL); // attaches the servo on pin 9 to the servo object
pinMode( PIN_LEFT_EYE , OUTPUT );
pinMode( PIN_RIGHT_EYE , OUTPUT );
pinMode( PIN_SWITCH , INPUT);
digitalWrite( PIN_SWITCH , HIGH );
}
void loop()
{
// Update the debouncer
bouncer.update ( );
// Get the update value
int value = bouncer.read();
// Turn on or off the LED
if ( value == LOW) {
// The switch is ON, as the pull-up resistor is being pulled low.
int jawAngle = random(60,100);
myservo.write(jawAngle);
int ledLevel = random( 0 , 255 );
analogWrite( PIN_LEFT_EYE , ledLevel );
analogWrite( PIN_RIGHT_EYE , ledLevel );
int delayTime = random( 100,500 );
delay(delayTime);
// Close the jaw again.
jawAngle = 100 ;
myservo.write(jawAngle);
delayTime = random( 100,500 );
delay(delayTime);
} else {
// The switch is OFF, so the pull-up resistor is pulling the voltage high.
// Turn everything off
int jawAngle = 100 ;
myservo.write(jawAngle);
int ledLevel = 0 ;
analogWrite( PIN_LEFT_EYE , ledLevel );
analogWrite( PIN_RIGHT_EYE , ledLevel );
delay(300);
}
}

















