Spooky Scary Mask – Final

 

This is the final project of the Spooky Scary Mask, if you want to review the first part of the prototyping (the distance detector, how to play sound), please click here.

This part of the spooky scary mask, the main focus is how to work with the solinoid/fluid pumps and the mechanical part of the project. The main goal for the mechanical part is to make the fake blook flush into the mask, to create the bloody scary effect.

Here is the fritzing sketch for this somewhat-working demo, whichi is not a whole lot more complicated than the previous one:

 

Here is the code, not much have changed from prototype part 1:

//JeanZhang_yihanz
//The Bloody Scary Mask - Part 1
//This code contains code and resources from this webpage:
//http://randomnerdtutorials.com/complete-guide-for-ultrasonic-sensor-hc-sr04/


//Set up the pins
const int trigPin = 11; //Trig - green Jumper - digital 
const int echoPin = 12; //Echo - yellow Jumper - pwm
const int soundPin = 5;

const int solinoid1 = 9;
const int solinoid2 = 8;

long duration, cm, inches;


//This is the function for a spooky sound (doesn't have to be exactly like this)
void scarySound() {
 for (int i = 100; i < 1000 ; i+= 20) {
 Serial.println(i);
 tone(soundPin, i);
 delay(50);
 }
 for (int i = 1000; i > 100; i-=20) {
 Serial.println(i);
 tone(soundPin, i);
 delay(50);
 }
 noTone(soundPin); // stop the sound after the trigger
}


void setup() {
 //Serial Port begin
 Serial.begin (9600);
 
 //Define inputs and outputs
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 pinMode(soundPin, OUTPUT);
 pinMode(solinoid1, OUTPUT);
 pinMode(solinoid2, OUTPUT);
}
 
void loop()
{
 digitalWrite(solinoid1, LOW);
 digitalWrite(solinoid2, LOW);
 
 
 // The sensor is triggered by a HIGH pulse of 10 or more microseconds.
 // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
 digitalWrite(trigPin, LOW);
 delayMicroseconds(5);
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);
 digitalWrite(trigPin, LOW);
 
 // Read the signal from the sensor: a HIGH pulse whose
 // duration is the time (in microseconds) from the sending
 // of the ping to the reception of its echo off of an object.
 pinMode(echoPin, INPUT);
 duration = pulseIn(echoPin, HIGH);
 
 // convert the time into a distance
 cm = (duration/2) / 29.1;
 inches = (duration/2) / 74; 
 
 Serial.print(inches);
 Serial.print("in, ");
 Serial.print(cm);
 Serial.print("cm");
 Serial.println();

//if the person is close enough, things will be triggered
 if (cm < 20){
 digitalWrite(solinoid1, HIGH);
 digitalWrite(solinoid2, HIGH);
 scarySound();
 }
 delay(250);
}

 

Reflection:

The coding and wiring part of the second half is not hard to figure out. However , the mechanical part is really hard to be done. Since I bought the mask from a Halloween store, and this is a part of a kid costume. The bloody “heart” is made for the force that can be applied by human hand. In this case however, the solinoids can’t apply

 

Leave a Reply