IMG_6316.JPG

itp

PCOMP Halloween Midterm: Kevin the Skull

Team:
-Cara Neel

-Dylan Dawkins

-Bora Aydintug

Idea:

To create a creepy, responsive Halloween skull that could interact with people who passed it.

Functionalities

  • Skull turning to follow a person if they walk past it

  • Skull laughing when someone gets close

  • Skull jaw movement to accompany laughing

  • Skull’s eyes to light up when someone gets close.

    **italics indicate things we changed/chose not to do.

Fabrication:

  • We purchased the skull and eyeballs from a Halloween supply store. To get access to the inside of the skull, we sawed off the back half. We also drilled holes to connect the jaw servo to the jaw, and to mount the skull on the larger head servo. We used the laser cutter and wood glue to build a mount/enclosure for the skull, to which we affixed the larger servo.

IMG_7215.JPG
IMG_7217.JPG
IMG_7219.JPG
IMG_7218.JPG

Serial Communication

  • We used p5 and PoseNet to create eyetracking so that the skull could follow people. We used serial communication to send servo angles to the head servo based on a person’s position (see video on bottom right.)

  • We used an ultrasonic sensor to send distance information from the Arduino to p5, which triggered the jaw movement and originally, a laugh sound in p5 (we scrapped that idea eventually, but you can see it in the lower left video.)

  • See the p5 code here.

Our final product, Kevin, was a skull who follows you around as you walk in front of him, and whose eyes light up red if you get too close.

Arduino code

#include <Servo.h>
//SERVO VARIABLES
Servo jawservo;
Servo headservo;
int jawServoPin = 9;
int headServoPin = 10;
int servoAngle = 0;
int angle = 90;
int d = 80;
int sound = 250;
int inData;
int el;
boolean change = false;
boolean triggered = false;
int counter = 0;
int trueHeadAngle = 90;
int LED = 11;
//
int byteArray [1];
int inByte;
int jawAngle = 30;
int headAngle = 90;
// ULTRASONIC SENSOR variables
long duration;
int distance;
const int trigPin = 5;
const int echoPin = 6;
//timer variables
const unsigned long interval = 1000;
const unsigned long interval2 = 7000;
unsigned long startMillis;
unsigned long currentMillis;
unsigned long startMillis2;
unsigned long currentMillis2;
void setup() {
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
  pinMode(LED, OUTPUT);
  jawservo.attach(jawServoPin);
  headservo.attach(headServoPin);
  while (Serial.available() < 0) {
    Serial.println("hello"); // send a starting message
    delay(3000);              // wait 1/3 second
  }
  startMillis = millis();
  startMillis2 = millis();
}
void loop() {
  currentMillis = millis();
  currentMillis2 = millis();
  //ULTRASONIC SENSOR CODE:
  // Clears the trigPin
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculating the distance
  distance = duration * 0.034 / 2;
  if (distance < 20) {
    if (currentMillis - startMillis >= interval) {
      change = ! change;
      startMillis = currentMillis;
    }
    if (change == true) {
      jawservo.write(30);
    }
    if (change == false) {
      jawservo.write(95);
    }
    digitalWrite(LED, HIGH);
  } else {
    digitalWrite(LED, LOW);
  }
//  if (currentMillis2 - startMillis2 > interval2) {
//      triggered = false;
//      Serial.println("STOPPPPPP");}
//  Serial.println(startMillis2 = currentMillis2);
  //Sends info over to p5:
   Serial.println(distance);
  if (Serial.available() > 0) {
    inData = Serial.parseInt();
    trueHeadAngle = map(inData, 0, 500, 130, 60);// maps eye data to motor
  }
  headservo.write(trueHeadAngle);
}
IMG_7296.JPG
IMG_7301.JPG
IMG_7305.JPG
PCOMP, ITPCaroline NeelComment