Introduction: A Halloween Scare Machine Using a PIR, a 3D Printed Pumpkin and the Troll Arduino Compatible Audio Pranker/practical Joke Board.
I got my reward a few weeks early to help write some examples of use and build an Arduino library in an attempt to make it a little easier to program.
So what is "The Troll" - it's an Arduino (UNO) compatible audio prank board, It has a ATMega 328P chip onboard, a select button (user programmable), a DIP switch (4 switches, user programmable), and a LDR (Photo resistor connected to A0). It has two audio jacks, you can use one to pass audio though - and have sounds from The Troll injected on top of the other audio. It also has a speaker header for connecting a on board speaker, and a small amp on board. An external speaker with good amp is recommended.
There is also a "external" trigger pin (Digital PIN 9), sensors can be hooked up to "trigger" a sound. (PIR sensor, sound sensor, limit switch, vibration sensor, just about any digital sensor that has one output can be used.)
We also have access to all the analog pins (A0 to A5) - A0 is being used by the LDR, this opens up the possibility of using I2C devices.
There are three ways to power it - 9v battery, ac to dc adapter, and usb, there is a jumper pin that needs to be set if you are using battery or the ac adapter jack.
There is a AP23582 chip that contains the audio samples.
There are 57 sounds contained on the chip.
To program The Troll you need an Arduino UNO with a removable chip - Yes we take the chip out of The Troll, and put it in an Arduino UNO and program it. - You must take care when doing this to not bend the pins, and always check to make sure the key on the chip matches the key on the socket. (The half circle in one end of the chip).
They come with a stock sketch from Patrick - but the real fun of this device, is programming it to do what you want. It's not hard to remove the chips, take your time, and be careful - that being said, we are not going to be responsible if you damage your chip or devices. DO this at your own risk.
Equipment and STL files:
For this example, you will need a 3D printer (or access to one that you can use for a while, my print took over 12 hours). * Optionally you can wait till closer to Halloween, and buy a plastic pumpkin, or ghost or whatever.
You may still want to 3D print a box for The Troll board.
I printed the "HalloweenPumpkinCover" from this remix, I decided not to use the pumpkin or the reset of this remix, because I wasn't sure about the size of the hole for the PIR sensor, nor sure about the size of the neopixel ring used. - This was ok, since the "cover" just lays flat on top of my box.
Other tools needed:
You may need a soldering iron (depending on which neopixel ring you get), you will probably need (or want) a step bit. I used a screw driver with the bit I have, but you may want to use a small drill.
You will probably need hot glue, or sticky back tape.
The Hardware is simple:
You need a "The Troll" board - honestly I'm not sure if these will be for sale beyond the kickstarter - so you may need to contact Patrick from his website.
A mini PIR sensor something like the one pictured above, or here. Just an example - Do your home work before buying anything - you maybe able to find these cheaper, or on Amazon, or Aliexpress if you prefer those sites.
Finally you'll need a neopixel ring (with at least 12 pixels) and I would recommend trying to get one with wires already soldered to it.
The ring with 16 pixels should also work, you'll want to change the code slightly for the larger pixel count.
I think anything bigger you'll have a hard time getting it to fit.
Step 1: 3D Printing......
On my Wanhao Duplicator I3 v1 this took a while to print. I used the model without support. At a resolution of .1 and 35% infill. With a natural PLA filament. The print was over 12 hours. It was one of the longest prints I've ever done, and I was just hoping nothing would go wrong. Nothing went wrong, and I got a pumpkin.
While, the pumpkin was printing - I printed the cover, and made a few other small things for a different project using a Wanhao Duplicator I3 plus - the cover print was at a resolution of .1 and 35% infill, using a gray PLA filament, and was a lot faster to print.
Nothing to do but wait....
Step 2: While We Wait..... (The Software)
Above are some of the tests after I waited for print to finish. - There is just an Arduino UNO with a Neopixel Ring (12 leds) inside. At this point, I didn't make any holes for the PIR, or anything.
At was more of too see if 12 pixels would light up the pumpkin, and just what kind of "animations" I could get out of it. The sketch used was just the Adafruit example sketch.
The orange, purple and yellow all looked pretty good too me.... I liked the white as well.
So at this point I set to work on making the sketch that would use The Troll board, and a PIR.
As I said before, I've been working on making some example and building an Arduino Library for the board - so I adapted one of the examples I made. And lifted some code from the Adafruit example.
My library - and code can be found here. The library can be installed via the Arduino Library manager.
The example for this project is called "TheTroll_SpookyArray_v2" and can be found in the example folder.
You will also need the Adafruit Neopixel library which can be installed via the library manager, if you don't have it.
I have a few videos on using TheTroll library, and example of how the external triggers work with my library.
External Trigger Video, Introduction to TheTroll board (A little long), The Troll with the Little Buddy Talker (LBT is a speech board also made by Patrick that uses the same audio chip) - Red Alert!, Using the DIP Switches, and finally This project - The Troll Arduino Audio Pranker Halloween Project (The video)
One of the hard things to do was to have the LED animations going while the sound was still playing, by setting the library to not delay the sound, and using the same sort of idea as the example Blink without delay, I was able to (more or less) have the animations going while the sound was still playing. - The timings are still a little off, (or in some cases a lot off), but I'm working on that.
This was done on lines 154 to 161 using a do while combination, and again on lines 170 and 183. The difference between the blink without delay example and this is I'm using a while and looking to see if the millis - previousMillis is still less than the length of the sound. Where the blink without delay is comparing to see if more time has passed, using a IF statement
I'm using DIP switch 4 to set the what the compare should be if the trigger is tripped. In this case, the PIR sensor output goes HIGH if it's tripped, stays HIGH for a little bit, and goes LOW.
So line 74 - 76 say, check dip switch (set the trigger to HIGH or LOW), check PIN9 (The external trigger pin) against the trigger value - if It does HIGH - set a flag.
Line 79 to 111 say - if the flag is set to pick a semi-randomized color, and animation (The colors can be changed if you don't like my choices here.) This is done with a switch case, which is a fast way of doing a bunch of IF statements.
In the library, I provide a way to read the DIP switch, that returns a number between 0 and 15, I also provide a way to just read one DIP switch from your main sketch, an example of that is on line 124 - The output for the DIP Switches go LOW if they are in the ON position, otherwise they are HIGH (In the OFF position). And line 124 says, if SW4 (switch 4) is ON then make trigger HIGH.
Lines 130 - 137 will play the sound from the sound library. Each call is made up of a the memory location of the sound on the chip, and how long of a delay to use. This function is currently a blocking function, which mean everything else stops while the sound plays. To over come this, I set the wait time to zero, and let the neopixel functions handle the delay.
Line 57 is an array of sounds we want to use in the pumpkin - I selected the 13 "spooky" or "halloweenie" sounds. More could be added, or these sounds could be changed to something else. (The sound library has 58 sounds, so this is just a small sample of them). These are random sounds when triggered, so if you add more, you'll want to remember to change line 133 which chooses the random sound to play. Each "name" of the sound clip is made up of a memory location of the sound on the chip, and a delay value.
I think that is about it for the software, there are other examples included in the Arduino Library for The Troll board. Feel free to explore, change, and share :-)
Step 3: The Build.....
After the printer was done, I started to test to make sure the neopixels would work and be bright enough.
I then, took a rotatory tool with a small drill bit, and drilled a small hole between the eyes as a pilot hole for the step bit. I just used the step bit with a manual screw driver, stopping every now and then to see if the PIR sensor would fit. I wanted it tight, and didn't use any type of glue or anything like that. So mainly it can be pushed back out if needed.
At that time, I also put a hole on the back side (using the rotatory tool and drill bit), which is where I was planning on running the wires out of - and I did for some of the demo/testing, but ultimately I probably should not have made the hole - because I decided to print the cover from the other pumpkin and use it.
So for the cover, I also used the step bit, and made a larger hole to run wire though, I off set the hole a little bit to try and keep them out of the way of the neopixels.
Using some sticky back tape, I taped the neopixel ring down, and using a little super glue (very little - just in case I want to get back inside for some reason) - I glued the cover to the bottom of the pumpkin.
My wires are just long enough, and the pumpkin now has a base to sit on, the base then sits on the box I designed - (It's just sitting on the box, not being held by anything - so yes, someone could come and knock it over)
And that is about it..... I would say this was a fast build, but I had to wait for the 3D printer - so really it was pretty slow..... :-)
Step 4: More Pictures.....
Just because I took a lot of pictures.... Here are some more....
Thanks for reading, I hope you enjoy this project, and get some use out of it.
Step 5: Suggestion Was Made to Paint the Eyes and Mouth....
A fellow backer to The Troll board suggested painting the eyes and mouth....
Sounds easy enough, but both are kind of hidden layers inside the print - but doable... just takes a little time.
I found a paint pen, with a opaque black - It says it's permanent but doesn't say what type of paint is in it... I bought the medium point, but probably should have gotten the fine point - still the results turned out ok.
And here are a few pictures.....
Participated in the