Hey Particle community! It’s Halloween and dolls are creepy so I decided to use a photon and IFTTT to make an iot haunted doll.
Check out the video tutorial here!
Technical Skills Covered in this tutorial:
- How to publish an event to the cloud
- How to connect with ifttt
What does this doll even do?
- Uses ifttt to turn the lights on and off
- Makes the doll’s head glow red
- Makes a mask move with a servo
Technical Components:
- Particle Photon
- Breadboard
- Male to male wires
- Resistors
- Hue lights
- Govee RBG LED strip lights
- Servo motor (micro servo would also work)
- PIR Sensor
- Battery pack
Non Technical Components
- Vinyl doll with removable head
- White acrylic paint
- Black acrylic paint
- Black/navy dye (optional)
- Fake blood
- Halloween mask
- Styrofoam block roughly the same size as the halloween mask
- Something to house the circuit
Steps:
Setup
- Attach the Photon to the breadboard
- Connect to Power
- Connect from the GND pin to the negative section on the side of your breadboard
- Connect from the VIN Pin to the positive section.
Wire the PIR Sensor
PIR( Passive Infra Red) sensors can detect the movement of things that emit heat, like warm bodies. The PIR sensor has three pins: 5V, OUT , and GND
1.Connect 5v to the positive side of your breadboard
2. Connect out to D1
3. Connect the ground pin to the negative side of your breadboard,
4. Now the PIR Sensor will be able to transmit signals to the D1 pin.
Program the PIR Sensor
We need our sensor code to do two main things: detect if the input to the pin is high or low voltage. If the input is high then motion has been detected. If it’s low then no warm body has moved.
-
Open Particle Workbench
-
Declare your sensor. Mine is called “motionSensor” and it is assigned to pin D1.
-
int motionSensor = D1;
-
Next create a variable called sensorState and set it to low since we want to start it off with no motion detected.
-
int sensorState = LOW;
-
Make another variable called sensorValue that is set to zero.
-
int sensorValue = 0;
-
Create a variable called led and declare it at pin D7. This is the photon’s onboard light.
-
int led = D7;
-
In the setup loop, tell our code that the sensor is an input.
-
inMode(motionSensor, INPUT);
-
Declare the onboard light as an output so we can later use it to test if our code is working as expected.
-
pinMode(led, OUTPUT);
-
Inside our loop function, set the value of sensor to be equal to the read of the sensor
-
sensorValue = digitalRead(motionSensor);
-
Digital write to the led to low so it starts off with the light off.
-
digitalWrite(led, LOW);
-
Create an if else statement. First let’s test to make sure that the sensor is working. Inside the if statement turn on the LED, keep it on for two seconds, then turn it off. Inside the else statement keep the light off
-
if(sensorValue == HIGH){
-
digitalWrite(led, HIGH);
-
delay(2000);
-
digitalWrite(led, LOW);
-
}else{
-
digitalWrite(led, LOW);
-
}
-
Write another if statement inside the first. Check if the sensor state matches the sensor value. If it doesn’t,have it update here.
-
if(sensorState == LOW){
-
sensorState = HIGH;
-
}
-
Then do the same within the else statement.
-
if(sensorState == HIGH){
-
sensorState = LOW;
-
}
-
Compile and flash your code.
-
Wave your hand in front of the sensor. If the sensor senses movement the blue light on your photon should turn on for two seconds. If it doesn’t work, check your wiring.
-
Inside the if statement we’re going to call the Particle publish function three times. Particle.publish() is a cloud function that allows you to push an event to the Particle Cloud. This means that any hook or application that is registered to listen to the event will be notified when it is called.
Our publish functions will take two strings. The first one is the event name and the second one is the event contents.
-
Our first instance of Particle Publish will contain the strings “hue” and “blink”. This will eventually make the lamps with our hue lights blink.
-
Particle.publish(“hue”, “blink”);
-
Our second instance will contain the strings “led” and “red”. This will eventually cue our led strip to change to red, the most sinister of all the led colors.
-
Particle.publish(“led”, “red”);
-
After this publish event, have the program keep the lights red for two seconds with delay(3000);
-
delay(2000);
-
Then call Particle publish for the last time and give it the strings “led” and “purple”. We’ll be using this to change the led lights back to purple, in tribute to Prince and because I think purple is a creepy color for a haunted house.
-
Particle.publish(“led”, “purple”);
-
Compile and flash your code.
Connect to IFTTT
Next we’re going to connect our particle device to a service called if this then that which will allow us to control smart devices through the cloud without having to wire them to our photon.
-
Go to ifttt.com and create an account.
-
Once you’re logged in, click on the “Create” button in the top right corner. Select the “Add” button next to the “If this” option
-
Search services for “Particle” You’ll have to log into your particle account and grant permissions.
-
Select the “new event published” trigger. Type in “hue” for the event name and “blink” for the contents.
-
Make sure the device name that the trigger is watching is the correct device.
-
Press the create trigger button. You have set up the if portion.
-
Now click the “Add” button next to the phrase “Then that”. Search the services for the smart light provider that you’re using.
-
Note: I used zigbee lights connected to my hue hub for lamp lights and govee LED strip lights for the LEDs around my doll. If you use the govee lights make sure to use the wifi version of the strip lights and not the bluetooth one. It doesn not work with the bluetooth version and I found out the hard way. You’ll need a pro ifttt account to use govee so feel free to use hue lights only if you don’t have a pro account.
-
Select the blink option.
-
Select the name you’ve given your lights and press “create action”.
-
Review your applet and press the “finish” button to set it up.
-
Test it out to make sure it’s working. There may be a bit of lag for new applets, but you can trigger the app to run by pressing the “check now” button to speed things up.
-
Repeat this process with your other publish functions and set of lights, selecting govee instead of hue. Feel free to experiment with the options available to you. If you see any things that interest you create an applet for them and have them be triggered by motion sensors.
Wire the Servo
Much like our PIR Sensor, the servo has three pins: the ground, the 5V, and the digital pin.
-
Connect male to male wires to them. Use the longest ones you have. I used a giant spool of wire so the jump scare could happen far away from the doll.
-
Connect the darkest colored pin to the ground in the negative section of our breadboard.
-
Connect the middle pin to the positive section.
-
Connect the final pin to D5.
Program the Servo
- Declare your motor at the top of the program, establishing its pin as D0. I named mine maskMotor.
1. Servo maskMotor;
- In setup, attach the motor to pin D0
1. maskMotor.attach(D0);
-
Servo motors operate between the degrees of zero and one eighty. Inside our sensor checking if statement, use maskMotor.write to set the motor to go to 180 degrees, delay for two seconds, and then go back to zero degrees.
-
maskMotor.write(180);
-
delay(2000);
-
maskMotor.write(0);
-
Compile and flash your code. Now that everything is programmed, let’s turn this from a standard circuit to a haunted doll.
The Creepy Crafty Part
-
Dolls are creepy by nature. We’re going to make this one even creepier. First, derobe the doll. Paint all of the vinyl portions with a layer of black paint, making sure to get all of the crevices.
-
While the paint is drying, begin distressing the doll clothes. Use your fabric dye to start the dying process now.
-
Once the black paint is dry, paint a coat of white acrylic paint over the doll, giving it a greyish, undead complexion.
-
Behead the doll and stab out its eyes. If this doll ever does come to life it will haunt you and then it will haunt me for telling you to do that in the first place. I accept this fate.
-
Shove part of your led strip into the doll’s head so its eyes will glow when it is triggered.
-
Wrap the wrest of the led strip around/ near the doll.
-
Put your Halloween mask around the block of styrofoam.
-
Attach chopsticks to your servo motor and shove them through the bottom of the foam block.
-
Put the styrofoam mask across from the doll and hide it behind a curtain, box, or other large object.
Attach the Circuit to the doll
- There are many options for attaching the circuit to the doll. I put my board on the doll’s lap and covered it with an old pillowcase, with the PIR sensor sensor sticking out. Now when you walk by the haunting begins.