Candle Fright Arduino Controller ITTT Mareyn Koenderman
by Alterrix in Circuits > Arduino
1077 Views, 6 Favorites, 0 Comments
Candle Fright Arduino Controller ITTT Mareyn Koenderman
For a school project called If This Then That I made a candle that functions as a game controller for a game that I created called Candle Fright.
The candle works with 2 Ultrasonic sensors and 3 leds. During the game you will hear monster noises. As soon as you hear the monsters you will have to wrap your hands around the candle to prevent yourself from dying, but don't cover it for too long, cause else the candle will turn off.
Link to a build of the game:
https://drive.google.com/file/d/1A9xjT8OgYswO6xRXnTstNeUddisTPcPz/view?usp=sharing
Supplies
2 Ultrasonic Senor
2 Yellow Led
1 Red Led
3 Resistor 220ohm
24 Jumper wires
1 Arduino Uno
1 Power cable
1 Cartboard/ Fire match box
Tin
Soldering Iron
Glue
Glue Gun
PCB
Stanley Knife
Candles/ Candle Wax
A Cooking Stove
A Knife
Scissors
Cooking Pot
Milk Carton Empty
The Concept
Since I am a huge fan of horror games I wanted to create something a bit spooky.
At the start I had no idea what I could make with Arduino since there were so many things I could choose from. So I got a bit overwhelmed, but after a bit of brainstorming I came with a idea of creating a game controller that would work with Unity. since alternative controllers spiked my interest earlier on.
Soon after I came with the concept of having a candle that actually emitted light like a real candle would. The idea would be that you had to cover the candle when you hear a monster and the candle would start to flicker like a real candle would when its deprived from oxygen.
Overall the game would have to be played in the dark to have the best light results and add to the overall spookiness.
TinkerCat and Hardware
Before I started this project I had done nothing with Arduino before. So I watched a few tutorials on how to get started.
The tutorials I followed
(12) Realistic Candle Light with LED Arduino PWM, DIY, How-to, Beginners - YouTube
After I watched these videos I knew what my circuit should look like and how I should get started on coding for the Arduino. To create a clear visual for myself on how to set everthing up I made a schematic in TinkerCat.
The Code
Arduino
As in the previous step explained I first started off with a few different tutorials and doing some experiments. In the picture you can see the final setup on a breadboard.
I ended up with a code that that senses when the player is covering both the Ultrasonic sensor meters within 15cm.
The lights of the candle will start to flicker, since the candle is deprived from oxygen. This will prevent the player from dying in the game, but if you do it for longer then 10 seconds the candle will turn off.
I also used a serial print function which sends the distance to the serial monitor. With the help of a package called Ardity I was able to send the distance information to Unity and read the data from there to use the distance info in a if statement in Unity.
This way I was able to check in Unity if the player was covering the candle and therefore a bool canDie would be set on either true or false
(the code of the Arduino can be found in a ino file at the bottom of this step)
Unity
The MyListener script would be in charge of reading the output from the Arduino. Based on that it could tell the game when the player is covering the candle and when not. It also contained a timer which would activate a function to turn off the candle in the Switcher script if it reached 10 seconds.
Then there is a collision script which would make a jumpscare play if the player isn't covering the candle or if the candle got turned off. It also resets the game after the jumpscare.
Packages used:
To create the connection between the Arduino and Unity I made use of a package called Ardity:
Ardity: Arduino + Unity communication made easy | Integration | Unity Asset Store
For the candle asset i used:
Downloads
Creating the Candle
Since I wanted a most realistic candle effect as possible I decided to make my candle out of real candle wax.
I decided to use plastic as my molt shape since I needed a material that let light through.
Candle 1.0
As a starter I purchased some candles .After that was done i needed a molt for my candle. I found a plastic container in which my Arduino fitted at the bottom. I started carving the top off and holes into the side so I could fit my Ultrasonic sensors in there. After that was done it was time to give it a coat of candle wax.
Unfortunaly since I was too hasty and didn't let the candle wax cool down I ended up burning my first molt...
Candle 2.0
So it was time for candle 2.0. This time I used a milk can that I cut open. With the top removed and a holes for the Ultrasonic sensors and the power cable it was time for a retry.
This time I let the candle wax cool down and it ended up working. Since the milk can was too big I ended up rotating it in the cooking pot so I could get a full round shape. I cut off any excess of wax and cut the holes back out and I ended up with my basic candle.
All I had left now to do was to create a lid and to create glue lines with the help of a gluegun for underneath the Ultrasonic sensor holes for the pcb board to rest on.
After the glue lines were dryed up I could start getting the proportions of the pcb board.
I started with laying the pcb board on top of the candle and marking any bit that was overlapping. After I did that I took my stanley knife and started cutting it off and finishing it with my scissors. Now the pcb board was able to fit inside the candle on the glue lines. I could now go on to the next step which was soldering.
Solder
For the soldering i used my Tinkercat circuit as a reference. I started off with marking my pcb board for the locations of the Ultrasonic sensors. After the locations were marked. I was able to go onto the next step which was to put the Ultrasonic sensors in place and start soldering them.
I found it a bit hard to solder the sensors since the pins were so close to each other. I ended up having to remove the tin since the lines touched each other on a few occasions. After the sensors were secured I started adding the power, trigger, echo and ground jumpwire cables to the pins with a bit of soldering. I then created one tin line for the ground.
All that was left after that were the power supply cables for the leds and the resistors that needed soldering. Since the resistors went straight into the ground tin line no extra jumpwire cabels were needed.
I ended up extending each wire by soldering 2 jumpwire cables together and covering it up with non conducting tape. So if the wires touched each other it wouldn't cause any problems. I did this because my wires were a bit to short to reach the Arduino inside the candle on the first test.
I also taped the wires together so it was a bit more organized.
What Did I Learn?
Things i have learned from ITTT
I never had any experience with Arduino before and I never really understood how power circuits worked, but because of this project I now have a basic understanding of both of them. I also know how I can hook up Arduino with Unity now. Ill probably use this knowledge to also experiment in the future with alternative game controllers.
I also learned how to solder and I also learned its not meant for me, cause I have a condition which makes me shake the whole time, so it made the soldering a bit hard especially with the Ultrasonic sensors, but overall I had fun working on the project nontheless.