Mr Pumpkin Head

Mr Pumpkin Head is an interactive jack-o-lantern who gets angry if you wake him. When he is ‘sleeping’ his eyes fade in and out and his mouth is still. If you remove his top the motion sensor is triggered and he wakes up, his eyes stop flashing and his nostrils flare. If you shake his top he gets angry and his teeth flash red.

int pirPin = 12; //digital 2
int brightness = 0;
int fadeAmount = 5;
int ledEyes = 11;
int ledNose = 10;
const int tiltSensorPin = 8;
const int ledTeeth = 7;
const int ledMouth = 4;

void setup(){
pinMode(pirPin, INPUT);
pinMode(ledNose, OUTPUT);
pinMode(ledEyes, OUTPUT);
pinMode(tiltSensorPin, INPUT);
digitalWrite(tiltSensorPin, HIGH);
pinMode(ledTeeth, OUTPUT);
pinMode(ledMouth, OUTPUT);

void loop(){
digitalWrite(ledTeeth, HIGH);
digitalWrite(ledMouth, LOW);
digitalWrite(ledMouth, HIGH);

analogWrite(ledEyes, brightness);
brightness = brightness + fadeAmount;
if(brightness == 0 || brightness == 255) {
fadeAmount =-fadeAmount;

int pirVal = digitalRead(pirPin);
analogWrite(ledNose, LOW);

//pinMode(pirPin, INPUT);
//digitalWrite(pirPin, HIGH);

if(pirVal == LOW){ //was motion detected
Serial.println(“Motion Detected”);
analogWrite(ledNose, HIGH);
if(pirVal == HIGH) {
analogWrite(ledNose, LOW);