Introduction: HackerBoxes 0011: HAX0R TREAT

Picture of HackerBoxes 0011: HAX0R TREAT

[cue theme music]

HAX0R TREAT: This month, HackerBox Hackers are exploring motion detection and wireless signaling between multiple microcontroller nodes to create pranks and tricks. This Instructable contains information for working with HackerBoxes #0011. If you would like to receive a box like this right to your mailbox each month, now is the time to subscribe at and join the revolution!

Topics and Learning Objectives for this HackerBox:

  • Setting up multiple battery-powered microcontroller nodes
  • Loading and modifying programs in the Arduino IDE
  • Using passive infrared motion detectors
  • Transmitting and receiving wireless messages
  • Implementing wireless communication network topologies
  • Using Servo Motors and LEDs for simple animatronics
  • Accessing USB storage devices from your projects

HackerBoxes is the monthly subscription box service for DIY electronics and computer technology. We are hobbyists, makers, and experimenters. Hack the Planet!

Step 1: HackerBoxes #0011: Box Contents

Picture of HackerBoxes #0011: Box Contents
  • HackerBoxes #0011 Collectable Reference Card
  • Three Arduino Pro Mini Modules
  • Three 9V Battery Clip Leads
  • Two 315Mhz Radio Frequency Data Transmitters
  • Two 315Mhz Radio Frequency Data Receivers
  • USB Serial Module (CH340)
  • Passive Infrared Motion Sensor (HC-SR501)
  • Two MAX7219 8x8 LED Matrix Modules
  • SG90 Micro Servo
  • Two-Channel Relay Module
  • 40 DuPont Female-Female Jumper Wires
  • USB Drive Read/Write Module (CH376S)
  • Headless Skeleton USB Flash Drive 4GB
  • Speaker (8ohm, 5cm)
  • Audio Jack 3.5mm
  • Two Passive Piezo Buzzers
  • Ten Mini-PCB Addressable RGB LEDs (WS2812B)
  • Exclusive BitHead Lapel Pin
  • Exclusive HAX0R TREAT Decal

Some other things that will be helpful:

  • Basic soldering and prototyping tools
  • Three 9V batteries
  • Electrical tape or heat-shrink tubing
  • Hot glue gun or other adhesive
  • Arduino Integrated Development Environment (IDE) [download]

Most importantly, you will need a sense of adventure, DIY spirit, and hacker curiosity. Hardcore hobbyist electronics isn't always easy, but when you persist and enjoy the adventure, a great deal of satisfaction may be derived from persevering and getting your projects working. Just take each step slowly, mind the details, and don't hesitate to ask for help.

Step 2: Tricks, Pranks, and Ad Hoc Wireless Signaling

Picture of Tricks, Pranks, and Ad Hoc Wireless Signaling

Halloween, or related Fall harvest festivals, are celebrated in different ways among various cultures around the world. Wikipedia has an amazingly detailed entry on the subject, which lists among typical Halloween activities: playing pranks. Even if you do not celebrate Halloween, these projects should provide plenty of fodder for pranking or surprising your friends and family for a birthday, other celebration, or just for fun!

The technology behind this month's pranking includes a simple platform for a peer-to-peer or ad hoc wireless signaling network. We will be working with three identical Arduino Pro Mini microcontroller "nodes" as well as two RF transmitters and two matching RF receivers for setting up wireless signaling between the processor nodes.

Step 3: Preparing the Arduino Pro Mini

Picture of Preparing the Arduino Pro Mini

The Arduino Pro Mini is a microcontroller board based on the ATmega328. We are using the 5V/16MHz variety. The Pro Mini was originally designed by SparkFun Electronics and has become quite popular thanks to its tiny footprint. While less than one square inch in area, the Pro Mini features 14 digital input/output pins, six analog inputs, a crystal oscillator, a voltage regulator, and a reset button.

Because the Arduino Pro Mini was intended for integration into other systems, it arrives without pre-mounted headers, allowing the use of various types of connectors or direct soldering of wires. For our purposes here, we will be interfacing the Pro Mini using female DuPont jumper wires, so we will start by vary carefully soldering in the provided header pins.

Warning: If you are new to soldering, really take your time with this. Go very, very slowly and take great care. There are a lot of guides and videos online about soldering. Here is one example. You might want to find an old junk PCB for some practice (un)soldering. If you feel that you need additional assistance, consider joining a local makers group or hacker space in your area. Also, amateur radio clubs are always excellent sources of electronics experience.

Battery Power: The Pro Mini has an on-board regulator allowing it to be run from a 5-12VDC unregulated power source. An easy example of which is a 9V battery. To make a header-pin friendly 9V battery, female connector ends from a DuPont jumper can be soldered onto the leads of a 9V battery clip. The connections can be covered with tape or heat-shrink tubing.

The red battery lead should be connected to the RAW pin of the Pro Mini. The RAW pin is the input to the onboard regulator. The black lead should be connected to any of the GND pins. There is some code preloaded onto the Pro Mini. This code will start running a few seconds after power is applied. The code will slowly blink an LED on the Pro Mini.

Step 4: CH340 USB Serial Module

Picture of CH340 USB Serial Module

A USB/Serial module allows a computer USB port to talk to the serial interface on a hardware device such as an Arduino microcontroller board. There are many different types of USB/Serial modules using various USB/Serial bridge chips. The CH340 chip from WCH is increasingly common and is relatively easy to use.

Your computer's operating system requires a Device Driver to communicate with the CH340 USB/Serial chip. The specific device driver that is needed depends upon both the OS version and also the type of USB/Serial chip. For the CH340 USB/Serial chips, there are drivers available for many operating systems (UNIX, Mac OS X, or Windows). WCH (the maker of the CH340) supplies those drivers here. The Google translate version may be helpful.

The CH340 USB/Serial module may be used in either 5V mode or a 3.3V mode. The jumper block on the module's header connector is used to select which of these modes is being used. Since our microcontroller modules are 5V and the jumper usually defaults to the 3.3V configuration, we will need to switch the jumper to 5V mode by shorting between the 5V pin and the VCC pin.

When the CH340 USB/Serial module is plugged into a PC, the power LED on the module should light up and the operating system should notice the connection of the USB/Serial chip. Within the Arduino IDE, a PORT item should appear indicating the USB/Serial module. If it does not, be sure that the appropriate driver is installed.

Once the CH340 PORT is selected within the IDE, the CH340 USB/Serial Module may be further tested by connecting the module's TX (transmit) and RX (receive) pins together using a female/female DuPont wire. Next, open the serial monitor in the Arduino IDE. Anything typed into the serial monitor will go out through the CH340 module's TX pin and right back into the RX pin to be displayed on the serial monitor. This is called an echo or loop-back test. Notice the operation of the three LEDs (power, tx, and rx) on the CH340 module.

Step 5: Loading Code Onto the Arduino Pro Mini

Picture of Loading Code Onto the Arduino Pro Mini

Once we've had the Arduino Pro Mini powered up and running and we have also seen the CH340 module working, we can put them together. This will let us program the Pro Mini from the Arduino IDE software running on your computer.

We can wire up the Arduino Pro Mini, CH340 USB/Serial Module, and 9V Battery Clip as shown. Note that the grounds of the Pro Mini, the CH340 Module, and the 9V Battery are all tied together. This is important so that all of the signals and supplies are referenced to the same 0V ground. For now, do not worry about the unused red 5V line in the circuit diagram. That is related to the power source footnote below.

Now that everything is wired up, we can plug the CH340 into a USB port on the computer, launch the Arduino IDE software, select the appropriate tools>port in the IDE for our USB port, and select "Arduino Pro or Pro Mini" in the IDE for tools>board.

Finally, load up a piece of example code:


This is actually the code that was preloaded onto the Pro Mini and should be running right now to blink the LED. Accordingly, if we load this code as it stands nothing will happen. Instead, let's modify the code a little bit. Looking closely, you can see that the program turns the LED on, waits 1000 milliseconds (one second), turns the LED off, waits another second, and then does it all again - forever.

Modify the code: change both of the "delay(1000)" statements to "delay(100)"

This mod will cause the LED to blink ten times faster, right?

Let's load the modified code into the Pro Mini and check:

  1. Press and Hold the reset button on the Pro Mini
  2. In the IDE, Click the UPLOAD button (the arrow icon) just above your modified code
  3. Watch below the code for the status info: "compiling" and then "uploading"
  4. As soon as it switches to "uploading" release the reset button on the Pro Mini
  5. The IDE should now say "Uploading Complete" and your LED should be blinking faster

If so, congratulations! You have just hacked your first code. If not, try again, sometimes the timing of the reset release is a little tricky. The transmit LED on the CH340 module should light up steady for a second or two while the upload occurs. When you don't see this (followed by an error on the IDE), the reset release is generally to blame. Just try it again until you get used to the proper timing.

Once your fast-flash version of blink is loaded and running, why not see if you can you change the code again to cause the LED to blink fast twice and then wait a couple of seconds before repeating? Give it a try! How about some other patterns? Once you succeed at visualizing a desired outcome, coding it, and observing it to work as planned, you have taken an enormous step in hardware hacking. Wear your new HackerBoxes BitHead pin with pride!

A note about the power source: While we want our project to be battery powered, it is actually possible to power the Pro Mini from the CH340 USB module (while the CH340 is plugged into a computer or USB power supply). Since the 5V pin on the CH340 Module is blocked by the configuration jumper on the header, you will have to solder a wire to the base of the 5V pin close to where it meets the circuit board (or even on the rear). This is illustrated by the unused red 5V line in the circuit diagram. When using this 5V CH340 source, the battery should be completely removed and the 5V line from the CH340 modules should connect to a VCC pin on the Pro Mini (not the RAW pin).

Step 6: Motion Activated Frightful Sci-Fi Sounds

Picture of Motion Activated Frightful Sci-Fi Sounds

The HC-SR501 (tutorial) is a motion detector based on a passive infrared (PIR) sensor. PIR sensors measure infrared (IR) radiation from objects in their field of view. All objects (at normal temperatures) emit heat energy in the form of radiation. This radiation is not visible to the human eye because it is mostly at infrared wavelengths. However, it can be detected by electronic devices such as PIR sensors.

Wire up the components as shown and load the example code to feast your ears on a simple demonstration of motion activated creepy noises. The activating motion also causes the example code to toggle the LED on the Pro Mini and output status to the serial monitor.

Step 7: Adding a Radio Frequency Transmitter

Picture of Adding a Radio Frequency Transmitter

We can extend our motion-activated buzzer project to also transmit the motion detection event to another Arduino Pro Mini using a radio frequency (RF) wireless message. We have two 315MHz RF transmitters and two RF receivers. The operating frequency 315MHz is used in the United States for a lot of simple unlicensed RF devices, such as garage door openers. In some other countries, different frequencies may be allowed for these types of devices. If you are not a licensed radio operator, make sure you are complying with the rules in your jurisdiction.

We can start by wiring one of the RF transmitters (the square one) into the project as shown in the wiring diagram. Note that you will run short on VCC (5V) and GND (0V) pins on the Arduino Pro Mini for wiring up all these peripherals at once. This can be mitigated by making a DuPont "splitter". Cut two female-female DuPont jumpers near their middles, strip the four resulting wire ends, solder them together, and then seal with tape or shrink tubing. You can now connect one of the four female connectors to a VCC (or GND) pin of the Pro Mini and then use the other three connectors for the additional modules.

The attached example code simply extends the motion-activated buzzer project to also transmit a message "A" over the 315MHz RF link using the VirtualWire Library (datasheet). VirtualWire is an Arduino library that provides features to send short messages over wireless using ASK (amplitude shift keying) modulation. The messages are sent without addressing, retransmit, or acknowledgment - a bit like UDP. VirtuaWire can be used with a number of simple radio transmitters and receivers. All that is required is one pin to transmit data and then one pin to receive data.

The VirualWire Library can be downloaded here. Start installing the library by extracting the entire folder from the downloaded zip file. Place the entire folder into your Arduino Libraries folder. Within the Arduino IDE, going into "manage libraries" will cause the IDE to scan the Libraries folder and grab any new libraries that have been added. This library will need to be added before the example code will compile.

Step 8: Set Up an RF Receiver on Another Arduino Pro Mini

Picture of Set Up an RF Receiver on Another Arduino Pro Mini

Wire up one of the 315MHz RF receivers (the rectangular one) up to another Pro Mini as shown in the wiring diagram. This will serve as the receive node for the message transmitted by our motion-detection circuit.

The attached example code also uses the VirtualWire Library to receive wireless messages from the 315MHz ASK link. If the message matches the one sent by the other Pro Mini ("A"), then the example code will turn on the LED to show that the message was received. In other words, when the motion detector is triggered on the other board, this one will light up its LED - even from a distance of ten meters or more.

The RF receivers can be used to remotely trigger servo motors, lights, noises, and various other prank-worthy animatronics as shown in the remainder of this instructable.

Antennas: The working distance between the transmitter and receiver is quite usable by default, but it can be extended by soldering some wire into the antenna ports on each of the 315MHz modules. How long should the wire be for a quarter-wavelength antenna? Different lengths, structures, and orientations of antennas may be fun to experiment with or encourage a young hacker to test as a science fair project. An amateur radio operator will be happy to talk to you at length (wavelength?) on the topic of antennas. Also, here are a couple of fun antenna textbooks:

Joseph Carr "Practical Antenna Handbook" [pdf]
Thomas Milligan "Modern Antenna Design" [pdf]

Step 9: Wireless Network Topologies

Picture of Wireless Network Topologies

Messages may be sent over wireless links or broadcast channels in order to realize various wireless network configurations, generally referred to as topologies.

In a simple point-to-point example, as we have already demonstrated, messages are sent from one node to another node.

In an unaddressed broadcast example, messages are sent from one node and then received at multiple other nodes. Keep in mind that one node (e.g. having the motion sensor) can broadcast a message that is received by a second node causing the second node to perform some action. At the same time, the same message, is also received by a third node triggering the third node to complete some other action. Either receiving node can use a delay() after message detection in order to allow the other receiving node to complete its action first. Such timing can cause the wireless relaying of messages to appear much more complex than it actually is.

In an addressed broadcast example, messages from a first node include a specific indicator as to which other node(s) should react to the message.

In a multiple point-to-point example, message contents can indicate which node the message originated at and then possibly also which node(s) should react to the message.

Step 10: Servo Motors

Picture of Servo Motors

This type of servo motor is a rotary actuator. A servo is generally controlled by a PWM (pulse width modulation) signal. These signals are generally a series of repeating pulses of variable width. These servos are connected through a standard three-wire connection: two wires for a DC power supply and one for control, carrying the pulses.

To get started with your servo motor, wire it up as shown. Pin9 is the PWM output from the Arduino that supplies the control pulses. One of the small arms may be temporarily pressed onto the servo (without a screw) just to see how it works. Once the servo is installed into a final application, the correct arm can be screwed on at the desired angle.

The example servo microcontroller combo can be combined with one of the RF receivers to make the servo radio controlled.

Step 11: RGB LED Pixel Mini PCBs - WS2812B

Picture of RGB LED Pixel Mini PCBs - WS2812B

Ready for some cool colored lights? The WS2812B (datasheet) is an individually-addressable red-green-blue (RGB) LED with an integrated controller and driver. We have ten of them on little round PCBs for easy soldering as needed. They are manufactured in a large sheet but can be individually separated from their neighbors with a gentle snap. As shown in the wiring diagram, these pixels can be easily chained together such that they only require a single I/O pin to control a large number of LEDs.

Click onto the github for Pololu's "Addressable RGB LED Strip" Arduino Library. Hit the "clone or download" button and download the library zip file. Extract the folder into your Library folder and tickle the IDE to go find the new library.

From the examples folder, load the "LedStripColorTester" project and change these two lines:
PololuLedStrip<6> ledStrip; // the RGB LEDs are on pin 6
#define LED_COUNT 2 // only two RGB LEDs connected

Download the code to the Pro Mini, launch the serial monitor, set the data rate to 115,200 baud and type R, G, B "triples" into the serial monitor to set the LED colors. For example:

  • "10, 0, 0" to get dim red
  • "200, 0, 0" to get bright red
  • "100, 0, 100" for purple
  • "0, 100, 0" for green
  • and so on

Step 12: Fright Skull With Servo Jaw and Firey LED Eyes

Picture of Fright Skull With Servo Jaw and Firey LED Eyes

The FRIGHT SKULL is an example of an animatron that can be triggered by a motion sensor or over a wireless RF link. This example skull was modified from a plastic toy to use a servo motor, some RGB LEDs, and a buzzer to put on quite a show.

Step 13: LED Matrix Scary Eyes

Picture of LED Matrix Scary Eyes

To make some scary eyes for another type of animatron, all you need is a couple MAX7219 8x8 LED Matrix Modules. The modules are wired together in a chain. The first MAX7219 module is wired to the Arduino Pro Mini and the second module is wired to the first module.

According to the sample code, the first MAX7219 should be wired like so:

  • Pin 10 of Pro Mini to the CS pin
  • Pin 11 of Pro Mini to the CLK pin
  • Pin 12 of Pro Mini to the DATA pin
  • VCC to VCC (5V)
  • GND to GND (0V)

Then just grab the .ino file from this LED Matrix Evil Eyes project.

You will also need the LedControl Library. The Library Manager in the Arduino IDE should be able to find that library and install it from within the IDE. All of the details about the library can be found here.

The RF receiver or IR motion sensor can be added to turn on the scary eyes or to trigger the motion of the pupils.

Step 14: Generating Simple Aglorithmic Sounds

Picture of Generating Simple Aglorithmic Sounds

This very simple speaker circuit and tiny program can generate some really interesting sounds beyond the piezo buzzer clicks we've been using. Note that this program directly takes over some of the low-level timers and registers of the microcontroller, so it may not play nicely with normal Arduino function also expecting to use those chip features.

This page has some great background information about generating algorithmic symphonies from one line of code.

You can connect a 3.5mm audio jack in place of the speaker in order to plug headphones or amplified speakers. Connect the audio output (pin 6) from the Arduino into both channels on the audio jack to have the sound driven to both speakers. This is considered dual-channel-mono, not proper stereo, since both channels contain the same signal.

Step 15: USB Drive Read/Write Module CH376S

Picture of USB Drive Read/Write Module CH376S

Have you ever wanted to read or write files to a USB drive from your microcontroller project? The CH376S module (datasheet) will let us do just that.

For a quick demo of how to read a file from a USB drive. Create a file on the drive called TEST.TXT and put some text information in it. Wire up the CH376S module as shown, load the sample code, set the Arduino IDE serial monitor to 9600 board. Enter the command "4" in the serial monitor to open a file on the USB flash and print the file contents out to the serial monitor.

Take a look here for the more detailed demo showing more features of the CH376S.

Note about wiring the CH376S: The reference card shows the pinouts for one version of the module, but many of the newer models have a different pinout and should be wired as shown in the wiring diagram here. Also, note that an optional parallel interface maybe used to get higher data transfer rates.

Step 16: Relay Module (Dual Channel)

Picture of Relay Module (Dual Channel)

A relay is basically a switch controlled by an electromagnet. As one example application, you can use a relay to switch a lamp on and off using the low voltage output from an Arduino as the control (example). Obviously this applies to other electrical appliances just as well as a lamp.

NOTICE: Using a relay to switch line voltages is obviously a very risky undertaking. In some jurisdictions, it may even be illegal to do so without the assistance of a licensed electrician. If you have any doubts about how to do this safely, how to put it into a proper housing, how to take all necessary precautions, if you are even allowed to do it, and so forth, then we strongly advise you to simply avoid the matter. Any experimentation with line voltages is against our advice and, like all maker activities, is at your own risk.

Since relays can be used to switch "low voltage" signals as well, there is plenty of fun that you can have experimenting with relays without taking the undue risk of messing around with line voltages. Looking at the example diagram for a set of commercial Halloween LED lights, we can see that there is a line voltage side and low voltage side. A relay could be used on either side, but obviously dealing with low voltage wires is a lot safer. There is no reason to cut the line voltage leads or to open the controller box. Again, if you are unsure about this sort of experiment, then we recommend steering clear.

Step 17: Hack the Planet

Picture of Hack the Planet

We hope you are hatching some great plans for pranks and tricks using motion sensing and wireless signaling. If you have enjoyed this Instrucable and would like to have a box of electronics projects like this delivered right to your mailbox each month, please join us by SUBSCRIBING HERE.

Please share your success in the comments below and/or on the HackerBoxes Facebook page. Certainly let us know if you have any questions or need some help with anything. Thank you for being part of the HackerBoxes adventure. Please keep your suggestions and feedback coming. HackerBoxes are YOUR boxes. Let's make something great!


KristianG16 (author)2016-10-05

In the wiring diagram for step 7 "Adding a Radio Frequency Transmitter", it looks like the blue and red wires going into the transmitter should be swapped around. The "ATAD" (or 'data' spelled backwards) pin is the left-most pin on the transmitter in that orientation, so the blue wire should be connected to that.

I also found I needed the transmitter/receiver within inches of each other to finally get the "A" character received (may just be due to circuit board orientation on the breadboards I'm working with), so I'll have to experiment with antennas. I can't wait to use some of this in my Halloween setup!

MikeO99 (author)KristianG162016-10-09

Kristian, have you solved the distance problem? I'm experiencing that my transmitter and receiver *must* be very close (less than a foot, generally) in order to send and receive the "A" signal as seen in the image attached...

tbrannam (author)MikeO992017-01-24

Range improved quite a bit by adding just a six inch wire to the transmitter. I can transmit across a room now.

Going to experiment a bit more, probably will try increased voltage next, and then add an antenna to the receiver.

tbrannam (author)tbrannam2017-01-24

This site talks about the 433 Mhz version, but the thread is pretty good, and has some great photos on the topic of antennas

chewie70 (author)MikeO992016-11-05

Looking at datasheet (not sure if this matches up to our parts exactly), looks like you can boost the transmitter by giving it up to 12v:

Haven't tried it yet but will when I find the time. So far my usable distance has been about 5 feet without antenna (the datasheet also has a recommendation for the antenna length).

KristianG16 (author)MikeO992016-10-12

Hey Mike, looks like a quarter wavelength antenna should be about 9 inches in length but I haven't had a chance to attach to the transmitter/receiver yet and check the results.

bdennis4 (author)2016-11-29

Delayed or Horibly Late (DHL)

NStet (author)2016-11-05

A totally newbe question, How do I install the CH340 driver in Ubuntu?

djcc2012 made it! (author)2016-10-13

If you want to make a really inexpensive version of the skull, I got one for $1 at Family Dollar. It is about 4.5" high x 6" long. All of the parts fit inside and the red led on the Arduino board looks neat glowing through.

I cut an access opening in the back of the skull, cut a hole above the eyes to insert the PIR from the inside and taped it in place. I cut holes into the eyes, put the LEDs against the holes and taped them in place. The rest of the parts are just lose inside. The Arduino, the Tx and the Piezo.

The two power wires are taped to the outside of the skull so that I can turn it off easily by removing them from the battery. It works great.

jrice19 (author)djcc20122016-10-31

I bought the same skull! It works great and is compact enough to go on a shelf.

eburman (author)djcc20122016-10-30

Nice job! I've got my Halloween skull working now with the PIR too. But my code modification simply runs through the loop if the PIR signal is HIGH. The LED's stay lit at the last color called once the PIR times out. I'd like to modify the code so that the LED blank out until the next time the PIR is triggered. Do you have a solution?

djcc2012 (author)eburman2016-10-30


Yes, here is my code. It is a mash up of the examples and some new code. It should handle your issue. :-)

// SkullProj1
// Oct 07 2016 DJS
// Uses PIR, Buzzer, RF TX, and LED

#include <RH_ASK.h> //Replaces VirtualWire for Tx/Rx
//#include <SPI.h> // Not actually used but needed to compile RH?
#include <PololuLedStrip.h>
#include <TimerFreeTone.h> //replace tone calls

#define LEDPIN 6 // Output pin for LEDs
#define LED_COUNT 2 // Number of LEDs
#define ledPin 13 // Test only
// Tx is on pin 12
// Need to leave pin 11, Rx, open for RadioHead

PololuLedStrip<LEDPIN> ledStrip; // setup LED control pin number
rgb_color colors[LED_COUNT]; // buffer for holding LED colors
rgb_color zero[LED_COUNT]; // buffer for 0,0,0 off

int buzPin = 3; // output pin for Buzzer
int PIRpin = 7; // input pin for PIR sensor
int PIRstate = LOW; // start with no motion detected
int val = 0; // variable for reading PIR status

RH_ASK driver; // Create RH_ASK instance
// RH_ASK driver(2000, 11, 12, 5); // Default speed, Rx, Tx, AntControl?

void setup()
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(buzPin, OUTPUT); // declare Buzzer as output
pinMode(PIRpin, INPUT); // declare sensor as input

rgb_color zero; // define LED off code = 0; = 0; = 0;

delay(1000); // wait 1 sec for Tx to power up
if (!driver.init()) // Check Tx
Serial.println("Tx init failed");

void loop()
val = digitalRead(PIRpin); // read PIR input value
// debug print val
// Serial.println(" PIR val = " [val]);
if (val == HIGH) { // check if the input is HIGH
// flicker eyes and sound while val is HIGH
fire(); // flicker "eyes" with fire colors
TimerFreeTone(buzPin,500*random(1,6), 250); // make random buzzer noises
if (PIRstate == LOW)
// PIR just turned on
Serial.println("Motion detected!");
PIRstate = HIGH; // Set HIGH and tell PM-2
driver.send((uint8_t*) "A", 1);
// driver.waitPacketSent(); // i think this is already in the send
// delay(200); may need to put back in
// digitalWrite(ledPin, LOW); // turn LED OFF
TimerFreeTone(buzPin, 0, 0, 0); // turn buzzer OFF, freq = 0
ledStrip.write(zero, LED_COUNT); // turn off eyes
if (PIRstate == HIGH)
// PIR just turned off
Serial.println("Motion ended!");
PIRstate = LOW;

void fire() // flicker "eyes" with fire colors
int i = random(0, LED_COUNT);
colors[i].red = random(60,150);
colors[i].green = random(0,50);
colors[i].blue = random(0,20);
ledStrip.write(colors, LED_COUNT);

eburman (author)djcc20122016-10-30

BRILLIANT!!! I lopped out the appropriate snippet of your code and shoved it where I thought it should go into mine and guess what? It works! Just in the nick of time for Halloween. Thanks so much!

eburman made it! (author)eburman2016-10-30

Here it is up and running.

djcc2012 (author)eburman2016-10-30

That looks great! Nice job. Enjoy scaring folks. :-)

jrice19 made it! (author)2016-10-31

Cool project! I liked this hacker box a lot the pro minis are very cool. I put the matrices in a real pumpkin and used a raspberry pi zero with a blinkt attached simulating a candle flickering. It turned out great! The blinkt actually looked better than a regular candle. I have a video of the project here Plastic pumpkins are the way to go here though i used plastic wrap but it was still a mess :) Happy hacking!

MikeM515 made it! (author)2016-10-30

My daughters and I worked on this one and had a lot of fun. We plan on making some changes to the eyes and putting the motion sensor and transmitter in a project box so we can put it on the porch. We are keeping this around for next year too!

DavidM1098 (author)2016-10-27

Using a Mac, I had no luck with the CH340 module. I had a PMPProg01/CP2102 and used that instead. Still took a while for the Arduino to take the upload, but it finally worked!

MichaelH539 made it! (author)2016-10-15

Just finished the "Terrifying Lego Man" project with my son. We used parts from this box as well as some other modules we got with the Digital Soundscapes HackerBox. Not sure if the videos will post as well, but we used servos to move the arms, added two of the RGB LED's for eyes, and added a speaker for a creepy "mama help me!" sound. The coding took a while to figure out, but I was surprised at how simple the electronics portion was to throw together. The Arduino boards are pretty amazing. Can't wait to see what is in next month's box!

Here is the code we used for the Lego Man portion of the project. The Wireless Transmitter is the same as the one shown in the examples. For anyone attempting to use both the RF transmitter and servos in a project, you will need to use the ServoTimer2 library instead of the regular Servo library. Otherwise, the program won't compile and you will get conflicts. Took us a few days to get all that worked out.

<-- Begin Code -->
#include <PololuLedStrip.h>
#include <ServoTimer2.h>
#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <SFEMP3Shield.h>
#include <VirtualWire.h>

SdFat sd;

SFEMP3Shield MP3player;
const uint8_t volume = 0;
const uint16_t monoMode = 3;

PololuLedStrip<5> ledStrip;

ServoTimer2 leftservo;
ServoTimer2 rightservo;

#define LED_COUNT 2
rgb_color colors[LED_COUNT];

int LEDpin = 13;
int RFrxPin = 12;
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen;

void setup() {
rgb_color color; = 0; = 0; = 0;
for(uint16_t i = 0; i < LED_COUNT; i++)
colors[i] = color;
ledStrip.write(colors, LED_COUNT);

void loop() {
if (vw_get_message(buf, &buflen))

void eyeson()
rgb_color color; = 255; = 0; = 0;
for(uint16_t i = 0; i < LED_COUNT; i++)
colors[i] = color;
ledStrip.write(colors, LED_COUNT);

void eyesoff()
rgb_color color; = 0; = 0; = 0;
for(uint16_t i = 0; i < LED_COUNT; i++)
colors[i] = color;
ledStrip.write(colors, LED_COUNT);

void armsdown()
leftservo.write(map(0, 0, 179, MAX_PULSE_WIDTH, MIN_PULSE_WIDTH));
rightservo.write(map(170, 0, 179, MAX_PULSE_WIDTH, MIN_PULSE_WIDTH));

void armsup()
leftservo.write(map(170, 0, 179, MAX_PULSE_WIDTH, MIN_PULSE_WIDTH));
rightservo.write(map(0, 0, 179, MAX_PULSE_WIDTH, MIN_PULSE_WIDTH));

void initSD()
if(!sd.begin(SD_SEL, SPI_HALF_SPEED))

void initMP3Player()
MP3player.setVolume(volume, volume);

void endMP3Player()

void TerrifyPeople()

eburman (author)MichaelH5392016-10-27

Fantastic! Well done! Very creative!

erilidon (author)2016-10-18

The amount of soldering that has to be done this month kinda put me off starting as I've been really busy... But just when I thought I was done I noticed this bad soldering job on one of the wireless receivers.

eburman (author)erilidon2016-10-27

So what do you expect from slave labor (political prisoners, 12 year old children, 16 hour work days)? Just one itty bitty blob of solder? The two pins share the same tracing so no harm done.

AlexandreS15 (author)2016-10-11

The CH341 driver causes an immediate kernel panic on Mac OS X Sierra and a reboot. As soon as the device is inserted, the Mac restarts. Any options? (I don't have a Linux PC around..

eburman (author)AlexandreS152016-10-27

I had the same problem occur when I popped in my USB/serial module. I thought maybe it was defective so I tried one that I had from box #8 that I knew was working before. Same problem, so it must be something to do with the Sierra update. I tried following the link suggested below but I wasn't able to make heads or tails of it. But, here is what did work for me: Check out the ReadMe.pdf that is provided along with the V1.3 install file that you need to download from WCH. If you read through the instructions you will see at the very bottom of the page that they suggests that you should uninstall any older driver versions using some specific terminal commands. Enter them exactly as written (it always makes me a little nervous when I delete files using sudo). It worked for me! No more kernel panic! It seems to be working fine for now.

HackerBoxes (author)AlexandreS152016-10-13

OS X Sierra fix:

JTronix (author)2016-10-22

Does the kit come with pin headers included?

wh0c4rez (author)JTronix2016-10-22

There are 40 female-to-female connectors, if that is what you are asking.

JTronix (author)wh0c4rez2016-10-25

No, im talking about the pins you solder to the arduino etc.

I do not believe it ha the pins.

ccarrella (author)JTronix2016-10-26

yes it does

RustinR made it! (author)2016-10-21

Here's my easy answer to the 5v power supply issue, No soldering to the board, jumper between VCC and 5v is still made.

KatrinaS31 (author)RustinR2016-10-23

Hey thanks. I was just about to start devising a non-solder method of power so I can reuse the mini if I want to. You saved me the trouble.

wh0c4rez made it! (author)2016-10-22

Previously posted as MikeO99. This is my motion activated light up skull...

mpawlina (author)2016-10-21

I'm also having some problems with transmission distance. It's saying up to 10 meters but mine transmitter and receiver loose connection if they are moved 6 inches apart. Anyone solved this problem? Or is it something I'm doing wrong?

JohnW534 made it! (author)2016-10-20

I added the LED spooky eyes to a few discarded books at the library I work at, and wrapped the LEDs / arduino in some black paper.

erilidon (author)JohnW5342016-10-20


AdamP95 (author)2016-10-04

I seem to have figured out the issue getting the arduino mini to
upload code, connect the CH340 to the mini like the picture, then remove
the 9v battery from the mini, and the jumper from the CH340, now
connect the VCC pins to each other.

Set up like this I am able to upload code to the mini.

HackerBoxes (author)AdamP952016-10-05

Thanks Adam.

There are a few different issues here, so let's pick them apart to share as much information as possible.

1. POWER: We obviously have to power the Pro Mini. Yes, it would be ideal to power it from the USB module while programming. (Pin 6 of the USB module is 5V right off the USB port, so that is best.) Using 9V into the RAW pin on the Pro Mini really should work as well assuming that the battery (and connections) are good and all of the grounds are tied together. A foolproof approach would probably be to leave the jumper block connecting 5V to VCC on the USB module and then use the "extra 5V line" (as shown in the diagram) to power VCC on the Pro Mini. That extra line can be made by cutting one connector off of a FF jumper wire and soldering the lose wire end to the 5V on the USB module (at the base of the pin or the reverse side of the pin - remove the jumper while soldering so it doesn't melt - but then put it back on).

2. JUMPER BLOCK: The jumper block on the USB module is needed (but is it always?) If you look at the schematic of the USB module (and the other instructions for the design), the module should not work at all without the jumper block since that is what provides VCC to the CH340 chip (selecting either 3.3V or 5V). That said, it seems to actually work fine for some people without the jumper, which is very confusing. One possibility is that even without its VCC powered up, the CH340 might be pulling power through its I/O pins (perhaps UD+/UD-). This is obviously very undesirable - even if it appears to work. Another possibility is that there are variants of the USB module PCB where the CH340 VCC pin is coupled in some way to the USB VCC (5V) to make sure that it works even if the jumper falls off. Perhaps if your USB module seems to work without the jumper block, you could buzz out the connections? For example, between USB 5V at whatever pin you are attaching to the Pro Mini. You mentioned using the VCC pin of the USB module, but from the schematic we can see that the VCC pin should actually be a power INPUT to the CH340 chip, not a supply to drive external boards from - potentially a bad idea.

3. RESET BUTTON: The reset of the microcontroller is an entirely unrelated issue to how the boards are powered. We ALWAYS have to do the reset. The point is to force the Pro Mini back through its bootloader (before it starts running whatever sketch happens to be on it). In the moment (after reset is released) that the Pro Mini passes through the bootloader, the programmer can grab the bootloader's attention and download the new sketch through it.

chewie70 (author)HackerBoxes2016-10-15

Has anyone had success with the CH340 being recognized under Windows 10 with the jumper setting to 5v? It works for me with the 3v jumper setting and without the jumper, but Windows complains when in the 5v configuration.

DesignerDavid (author)chewie702016-10-18

I was lazy and had already put my soldering iron away so didn't want to solder the vcc from the arduino to the ch340. So what I did was remove the jumper from 5v to vcc on the ch340 and used female-to-male jumpers from 5v and vcc on the ch340 and put them on the same row on the breadboard so in essence using the breadboard row for a jumper. Then I tapped off that same row with a female-to-male jumper and connected it to vcc on the arduino. Worked perfectly.

Hopefully the picture will make sense. The orange at the top of the picture is 5v on the ch340 and black is vcc. The purple jumper is the tap from the orange and black jumpers to vcc on the arduino.

chewie70 (author)DesignerDavid2016-10-18

Interesting solution - next change I get I will try this out.

mainegeek (author)chewie702016-10-16

I use Windows 10 and I was able to get it to connect after removing the jumper and connecting VCC to VCC. It seems the consensus is you probably shouldn't do that but I have had no problems so far.

chewie70 (author)mainegeek2016-10-18

Thanks maingeek - that is what I have been doing too, and it seems to be working fine. I was hoping there was some step I was missing to get it working with the jumper correctly set. Oh well.

djcc2012 (author)HackerBoxes2016-10-07

I connected the Pro Mini to the 9v for power as described and attached the CH340 with the jumper on 5V. It seems to have burned out the Pro Mini regulator. The Pro Mini ran fine from the 9V alone. After hooking to the PC via the CH340 it would not run at all. I checked the voltage on the Pro Mini with just the 9V attached after removing the the CH340 from the PC. 8+V are getting thru to the TX, RX and VCC pins.

mainegeek (author)djcc20122016-10-07

Are you certain? I've done that multiple times through this project and haven't hurt any of the 3 arduinos. I had one that stopped uploading code and I thought I had fried it but it was me being an idiot and wired Tx -> Tx and Rx - Rx. I do think a ground on one of my boards is fried though. Might just need to re-do the solder though

djcc2012 (author)mainegeek2016-10-08

Mini was working fine before I hooked it up to the USB. While both power sources were attached, 9V to Mini Raw and dongle jumpered to 5V connected to PC USB 5V, both the USB dongle and the Mini started to flash their lights very rapidly. I pulled out the dongle. All lights went out on the dongle and the Mini, even though 9V was still attached.

To test I rehooked up the dongle, GND, RX and TX to the Mini GND, TX and RX. Attached 9V + to Mini RAW and 9V - to Mini GND. Dongle was NOT attached to PC.

Battery reading is 9.6v
Mini did not power up. The dongle did not power up.
Readings on Mini Pins are:
Raw - 9.6
ACC - 0
VCC - 0
Tx - 0
Rx - 0

So, I removed the 9V and plugged the dongle into the PC. No power lines are attached from the dongle to Mini. Dongle powered up, Mini powered up. Dongle has blue power light solid and red light blinking very fast, Mini has red power light solid and P13 blinking very fast.

Dongle blue solid, red flashing
5v - 5.06 not hooked to Mini
3v - 3.31 not hooked to Mini
Tx - 3.72
Rx - 3.97

Mini power solid, P13 flashing
Raw - 0
ACC - 3.3
VCC - 3.1
Tx - 3.4
Rx - 3.4

When I attach the 5V from the dongle, the Mini has 5V readings on VCC and ACC. Raw is .2. Pretty sure my Raw input is trashed.

mainegeek (author)HackerBoxes2016-10-05

I believe the mini is getting powered by the I/O pins. I noticed with just the I/O pins and ground connected the Pro mini still powers up when the USB adapter is plugged into a computer.

Anthus (author)AdamP952016-10-04

This hasn't seemed to make a difference for me.

Are you still doing the hold reset and release it upon "uploading" part?

HackerBoxes (author)Anthus2016-10-05

You always have to do the RESET part - hold reset during compile and let it go just as compiling switches to uploading.

mainegeek (author)AdamP952016-10-04

Thanks. That worked perfectly. I was already powering the Arduino w/o the battery but I never thought to hook up the VCC's.

x2475 (author)2016-10-18

Who has been brave enough to use the USB skeledrive? Seriously any thumb drive coming from anywhere but standard retailers worry me.

About This Instructable




More by HackerBoxes:HackerBox 0026: BioSenseHackerBox 0025: Flair WareHackerBox 0024: Vision Quest
Add instructable to: