Using Fitbit to Make Scary Movies Scarier
by donutsorelse in Circuits > Wearables
443 Views, 4 Favorites, 0 Comments
Using Fitbit to Make Scary Movies Scarier
One of the staples of Halloween season is to binge watch scary movies. When the stars really align and the phone rings right after The Ring ends, or lightning strikes in the distance right as the killer appears, it adds an unparalleled exciting ambience. But, what if things could happen in the room during scary movies but not by chance? By using a Fitbit, I could monitor my wife's heart rate and, as the scary part of horror movies increased her heart rate, I could make things happen in the room accordingly. What's more in the Halloween spirit than going to unnecessary lengths to scare people?
Supplies
- Fitbit
- Arduino
- Computer
- Smart Lights/Smart Dimmers
- Sound Effects
Chattin' With Fitbit
First we have to be able to actually pull data from the Fitbit, so we need to bring over some freshly baked cookies and kickoff our communication. Start by going to https://dev.fitbit.com/apps/new to register a new app.
You'll want to login as the account associated with the Fitbit. This saves a LOT of hassle.
The main field to note is Oauth 2.0 Application type, which should be set to Personal. For your Redirect URL, you can just use http://localhost . All the names and URLs can be filled in with anything, since it's a personal app and you don't exactly need to write a Privacy Policy for yourself.
Now click the OAuth 2.0 tutorial page. This is where you're going to get your access token, as well as where you can easily see your client ID.
Click the authorization URL they generate for you. You'll set the permissions you want, and then when you press allow you'll see a "This site can't be reached" page. This is completely fine and expected. Just copy that URL and go back in to the tutorial page. Paste it into the box under Parse response, and under step 3 you can see your access token. This is all you need to get going with the next steps, where we get Fitbit data and use it to do fun things.
Python Magic
Python is sorcery. This is one of my first encounters with Python ever and it just kind of works right away. To add anything you don't have, you just pip install it and it just works. I'm using Kasa smart dimmers so that's what I have setup in the code. Depending what you already have, you'll likely need to run the following:
pip install python-kasa
You'll also likely need to pip install playsound as well.
I've noted in the code what needs added in, but you can drop in your access token and user id from the Fitbit step in to kick things off.
The code is included in this step. I'm certain that there's room for code improvements, but this isn't exactly an enterprise application. We're just here to have some fun with scary movies for Halloween time.
Here's how it works - every 30 seconds, we pull data from Fitbit. We look at the most recent point of data we get and see if it's new so that we don't just spam the same event over and over. As it turns out, the Fitbit will only sync data every 15 minutes, but, in standard programmer fashion, I saw that as a feature. It's no fun if scary things are constantly triggering, because you know they're coming and you get desensitized to it. Waiting between occurrences was something I wanted to do anyway, so this just kind of made that happen in a different way.
I usually like to randomize things, but in this case I decided to have different events trigger based on certain heart rates. That way the scariness would escalate as her heart rate did, and as an added for-funzies bonus I could know what my wife's heart rate was during the movie.
Beyond messing with the lights, I added in spooky sounds. To add these in, put some sound files into the same directory as your python file and it'll just work out of the box by referencing the sound file's name (eg. 'scream1.mp3').
Downloads
Room Interactions
Controlling lights and playing sounds is a solid start, but I wanted things to physically happen in the room. Cue Arduino.
I thought "what would be a scary thing to have happen in the room" and the conclusion I came to was that something randomly falling would do the trick. My setup was a bit comical, but if it works it works, right? I used a toilet paper roll around a servo that can rotate 360 degrees and attached a string to it. I ran the string to a stand of mine and set it slightly off balance to make it easier to trigger. This way, the servo pulled the string around the toilet paper roll and caused the stand to fall.
Since I only had 1 Arduino interaction setup, I went ahead and just triggered it as soon as there was something sent over serial. However, it'd be very easy to run different functions based on the serial message.
I also included a failsafe where the Arduino event would trigger after a set amount of time if it hadn't happened already, because not having things fall during a scary movie sounds tragic.
The code for Arduino is included in this step.
Downloads
Break Out the Popcorn!
The lights are ready to flicker and dim, creepy sounds are ready to roll, and a surprise crash is ready to rock. It's time to start a scary movie and hope it gets spooky enough to trigger some effects.
Hopefully you can find something scary enough, or someone scared-y enough to make this work, but if not the code is easily modifiable such that you can make it run regardless of the Fitbit interaction.
It's definitely a lot of fun to have scary stuff happen in the room during the movies, and I'm more than a little curious what people can come up with to add onto this! Enjoy!