loading

[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 HackerBoxes.com 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

  • 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

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

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

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

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:

File->Examples->Basics->Blink

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

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

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

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

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

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

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

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

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

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

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)

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

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!

<p>In the wiring diagram for step 7 &quot;Adding a Radio Frequency Transmitter&quot;, it looks like the blue and red wires going into the transmitter should be swapped around. The &quot;ATAD&quot; (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. <br><br>I also found I needed the transmitter/receiver within inches of each other to finally get the &quot;A&quot; 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!</p>
<p>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 &quot;A&quot; signal as seen in the image attached...</p>
<p>Range improved quite a bit by adding just a six inch wire to the transmitter. I can transmit across a room now. </p><p>Going to experiment a bit more, probably will try increased voltage next, and then add an antenna to the receiver. </p>
<p>This site talks about the 433 Mhz version, but the thread is pretty good, and has some great photos on the topic of antennas</p><p><a href="http://www.meteocercal.info/forum/Thread-Looking-for-best-Antenna-model-your-opinion-on-exotic-designs?page=5" rel="nofollow">http://www.meteocercal.info/forum/Thread-Looking-f...</a></p>
<p>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:<br><br><a href="http://www.robotshop.com/media/files/PDF/datasheet-im120628013.pdf" rel="nofollow">http://www.robotshop.com/media/files/PDF/datasheet...</a></p><p>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).</p>
<p>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.</p>
Delayed or Horibly Late (DHL)
<p>A totally newbe question, How do I install the CH340 driver in Ubuntu?</p>
<p>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&quot; high x 6&quot; long. All of the parts fit inside and the red led on the Arduino board looks neat glowing through. </p><p>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. </p><p>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. </p>
<p>I bought the same skull! It works great and is compact enough to go on a shelf. </p>
<p>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?</p>
<p>eburman</p><p>Yes, here is my code. It is a mash up of the examples and some new code. It should handle your issue. :-)</p><p>//<br>// SkullProj1<br>// Oct 07 2016 DJS<br>// Uses PIR, Buzzer, RF TX, and LED<br>//<br><br>#include &lt;RH_ASK.h&gt; //Replaces VirtualWire for Tx/Rx<br>//#include &lt;SPI.h&gt; // Not actually used but needed to compile RH?<br>#include &lt;PololuLedStrip.h&gt;<br>#include &lt;TimerFreeTone.h&gt; //replace tone calls<br><br>#define LEDPIN 6 // Output pin for LEDs<br>#define LED_COUNT 2 // Number of LEDs<br>#define ledPin 13 // Test only<br>// Tx is on pin 12<br>// Need to leave pin 11, Rx, open for RadioHead<br><br>PololuLedStrip&lt;LEDPIN&gt; ledStrip; // setup LED control pin number<br>rgb_color colors[LED_COUNT]; // buffer for holding LED colors<br>rgb_color zero[LED_COUNT]; // buffer for 0,0,0 off<br><br> int buzPin = 3; // output pin for Buzzer<br> int PIRpin = 7; // input pin for PIR sensor<br> int PIRstate = LOW; // start with no motion detected<br> int val = 0; // variable for reading PIR status<br> <br> RH_ASK driver; // Create RH_ASK instance<br> // RH_ASK driver(2000, 11, 12, 5); // Default speed, Rx, Tx, AntControl?<br> <br> void setup()<br> {<br> pinMode(ledPin, OUTPUT); // declare LED as output<br> pinMode(buzPin, OUTPUT); // declare Buzzer as output<br> pinMode(PIRpin, INPUT); // declare sensor as input<br> <br> rgb_color zero; // define LED off code<br> zero.red = 0;<br> zero.green = 0;<br> zero.blue = 0;<br><br> Serial.begin(9600);<br> delay(1000); // wait 1 sec for Tx to power up<br> if (!driver.init()) // Check Tx<br> Serial.println(&quot;Tx init failed&quot;);<br> }<br> <br> void loop()<br> {<br> val = digitalRead(PIRpin); // read PIR input value<br> // debug print val<br> // Serial.println(&quot; PIR val = &quot; [val]); <br> if (val == HIGH) { // check if the input is HIGH<br> // flicker eyes and sound while val is HIGH<br> fire(); // flicker &quot;eyes&quot; with fire colors<br> TimerFreeTone(buzPin,500*random(1,6), 250); // make random buzzer noises<br> if (PIRstate == LOW)<br> {<br> // PIR just turned on<br> Serial.println(&quot;Motion detected!&quot;);<br> PIRstate = HIGH; // Set HIGH and tell PM-2<br> driver.send((uint8_t*) &quot;A&quot;, 1);<br> // driver.waitPacketSent(); // i think this is already in the send<br> // delay(200); may need to put back in<br> }<br> delay(10);<br> }<br> else <br> {<br>// digitalWrite(ledPin, LOW); // turn LED OFF<br> TimerFreeTone(buzPin, 0, 0, 0); // turn buzzer OFF, freq = 0<br> ledStrip.write(zero, LED_COUNT); // turn off eyes <br> if (PIRstate == HIGH)<br> {<br> // PIR just turned off<br> Serial.println(&quot;Motion ended!&quot;);<br> PIRstate = LOW;<br> }<br> }<br> }<br><br>void fire() // flicker &quot;eyes&quot; with fire colors<br>{<br> int i = random(0, LED_COUNT);<br> colors[i].red = random(60,150);<br> colors[i].green = random(0,50);<br> colors[i].blue = random(0,20);<br> ledStrip.write(colors, LED_COUNT); <br>}</p>
<p>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!</p>
<p>Here it is up and running.</p>
<p>That looks great! Nice job. Enjoy scaring folks. :-)</p>
<p>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 https://www.facebook.com/Jeffryrice/videos/10154882139174305/. Plastic pumpkins are the way to go here though i used plastic wrap but it was still a mess :) Happy hacking!</p>
<p>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!</p>
<p>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!</p>
<p>Just finished the &quot;Terrifying Lego Man&quot; 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 &quot;mama help me!&quot; 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!<br><br>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.<br><br>&lt;-- Begin Code --&gt;<br>#include &lt;PololuLedStrip.h&gt;<br>#include &lt;ServoTimer2.h&gt;<br>#include &lt;SPI.h&gt;<br>#include &lt;SdFat.h&gt;<br>#include &lt;SdFatUtil.h&gt;<br>#include &lt;SFEMP3Shield.h&gt;<br>#include &lt;VirtualWire.h&gt;<br><br>SdFat sd;<br><br>SFEMP3Shield MP3player; <br>const uint8_t volume = 0;<br>const uint16_t monoMode = 3;<br><br>PololuLedStrip&lt;5&gt; ledStrip;<br><br>ServoTimer2 leftservo;<br>ServoTimer2 rightservo;<br><br>#define LED_COUNT 2<br>rgb_color colors[LED_COUNT];<br><br>int LEDpin = 13;<br>int RFrxPin = 12;<br>uint8_t buf[VW_MAX_MESSAGE_LEN];<br>uint8_t buflen; <br><br>void setup() {<br> pinMode(5,OUTPUT);<br> pinMode(LEDpin,OUTPUT);<br> digitalWrite(LEDpin,LOW);<br> vw_set_rx_pin(RFrxPin); <br> vw_setup(4000); <br> vw_rx_start(); <br> rgb_color color;<br> color.red = 0;<br> color.green = 0;<br> color.blue = 0;<br> for(uint16_t i = 0; i &lt; LED_COUNT; i++)<br> {<br> colors[i] = color;<br> }<br> ledStrip.write(colors, LED_COUNT);<br> initSD();<br> initMP3Player();<br>}<br><br>void loop() {<br> buflen = VW_MAX_MESSAGE_LEN;<br> if (vw_get_message(buf, &amp;buflen))<br> {<br> if(buf[0]=='A')<br> {<br> digitalWrite(LEDpin,HIGH);<br> TerrifyPeople();<br> digitalWrite(LEDpin,LOW);<br> }<br> }<br>}<br><br>void eyeson() <br>{<br> rgb_color color;<br> color.red = 255;<br> color.green = 0;<br> color.blue = 0;<br> for(uint16_t i = 0; i &lt; LED_COUNT; i++)<br> {<br> colors[i] = color;<br> }<br> ledStrip.write(colors, LED_COUNT);<br>}<br><br>void eyesoff()<br>{<br> rgb_color color;<br> color.red = 0;<br> color.green = 0;<br> color.blue = 0;<br> for(uint16_t i = 0; i &lt; LED_COUNT; i++)<br> {<br> colors[i] = color;<br> }<br> ledStrip.write(colors, LED_COUNT);<br>}<br><br>void armsdown()<br>{<br> leftservo.attach(4);<br> rightservo.attach(3);<br> leftservo.write(map(0, 0, 179, MAX_PULSE_WIDTH, MIN_PULSE_WIDTH));<br> delay(500);<br> rightservo.write(map(170, 0, 179, MAX_PULSE_WIDTH, MIN_PULSE_WIDTH));<br> delay(500);<br> leftservo.detach();<br> rightservo.detach();<br>}<br><br>void armsup()<br>{<br> leftservo.attach(4);<br> rightservo.attach(3);<br> leftservo.write(map(170, 0, 179, MAX_PULSE_WIDTH, MIN_PULSE_WIDTH));<br> delay(500);<br> rightservo.write(map(0, 0, 179, MAX_PULSE_WIDTH, MIN_PULSE_WIDTH));<br> delay(500); <br> leftservo.detach();<br> rightservo.detach();<br>}<br><br>void initSD()<br>{<br> if(!sd.begin(SD_SEL, SPI_HALF_SPEED)) <br> sd.initErrorHalt();<br> if(!sd.chdir(&quot;/&quot;)) <br> sd.errorHalt(&quot;sd.chdir&quot;);<br>}<br><br>void initMP3Player()<br>{<br> MP3player.begin();<br> MP3player.setVolume(volume, volume);<br> MP3player.setMonoMode(monoMode);<br>}<br><br>void endMP3Player()<br>{<br> MP3player.end(); <br>}<br><br>void TerrifyPeople()<br>{<br> digitalWrite(LEDpin,HIGH);<br> vw_rx_stop();<br> delay(20);<br> initMP3Player();<br> delay(20);<br> eyeson();<br> delay(500);<br> armsup();<br> armsdown();<br> delay(500); <br> MP3player.playMP3(&quot;help.wav&quot;);<br> delay(2500);<br> endMP3Player();<br> delay(20);<br> armsup();<br> armsdown();<br> armsup();<br> armsdown();<br> delay(500);<br> eyesoff();<br> delay(20);<br> vw_rx_start();<br> delay(2000);<br> digitalWrite(LEDpin,LOW);<br>}</p>
<p>Fantastic! Well done! Very creative!</p>
<p>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.</p>
<p>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.</p>
<p>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..</p>
<p>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.</p>
<p>OS X Sierra fix:</p><p>https://tzapu.com/ch340-ch341-serial-adapters-macos-sierra/</p>
<p>Does the kit come with pin headers included?</p>
<p>There are 40 female-to-female connectors, if that is what you are asking.</p>
<p>No, im talking about the pins you solder to the arduino etc.</p><p>I do not believe it ha the pins.</p>
<p>yes it does </p>
<p>Here's my easy answer to the 5v power supply issue, No soldering to the board, jumper between VCC and 5v is still made.</p>
<p>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.</p>
Previously posted as MikeO99. This is my motion activated light up skull...
<p>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?</p>
<p>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.</p>
<p>Awesome!</p>
<p>I seem to have figured out the issue getting the arduino mini to <br>upload code, connect the CH340 to the mini like the picture, then remove<br> the 9v battery from the mini, and the jumper from the CH340, now <br>connect the VCC pins to each other.</p><p>Set up like this I am able to upload code to the mini.</p>
<p>Thanks Adam.</p><p>There are a few different issues here, so let's pick them apart to share as much information as possible.</p><p>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 &quot;extra 5V line&quot; (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).</p><p>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.</p><p>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.</p>
<p>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.</p>
<p>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. </p><p>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.</p>
<p>Interesting solution - next change I get I will try this out.</p>
<p>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.</p>
<p>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.</p>
<p>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. </p>
<p>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 -&gt; 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</p>
<p>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. <br><br>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. <br><br>Battery reading is 9.6v<br>Mini did not power up. The dongle did not power up.<br>Readings on Mini Pins are:<br>Raw - 9.6<br>ACC - 0<br>VCC - 0<br>Tx - 0<br>Rx - 0<br><br>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. <br><br>Dongle blue solid, red flashing<br>5v - 5.06 not hooked to Mini<br>3v - 3.31 not hooked to Mini<br>Tx - 3.72<br>Rx - 3.97<br><br>Mini power solid, P13 flashing<br>Raw - 0<br>ACC - 3.3<br>VCC - 3.1<br>Tx - 3.4<br>Rx - 3.4<br><br>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. </p>
<p>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. </p>
<p>This hasn't seemed to make a difference for me. </p><p>Are you still doing the hold reset and release it upon &quot;uploading&quot; part?</p>
<p>You always have to do the RESET part - hold reset during compile and let it go just as compiling switches to uploading.</p>
<p>Thanks. That worked perfectly. I was already powering the Arduino w/o the battery but I never thought to hook up the VCC's.</p>
<p>Who has been brave enough to use the USB skeledrive? Seriously any thumb drive coming from anywhere but standard retailers worry me.</p>

About This Instructable

20,265views

21favorites

License:

More by HackerBoxes:HackerBoxes 0019: Raspberry WiFi HackerBoxes 0018: Circuit Circus HackerBoxes 0017: Power Maker 
Add instructable to: