I have always wanted to make something with my LED dot matrix display, and so when I found a old alarm motion sensor I knew just what to make, a Motion Sensing Eye!
This instructable will hopefully finish with you having a working dmd, that will display an eye that opens if something in a room moves (above in the pictures are some gifs of it in action). This instructable will also be updated with bluetooth and android support in the near future (when I get it working).
Anyway, Let's Go!
- added optional shield
Step 1: Materials
Things you will need:
- An Arduino or similar
- A Freetronics Dot Matrix Display
- Arduino link cable for dmd
- An alarm sensor
- Mini breadboard and jumper cables
- A 10k resistor
- Power supply for the alarm sensor
- Usb cable for arduino
- Arduino Prototype shield
- Stackable headers
- Tactile push buttons
- Terminal Blocks
Coming Soon Eventually:
- Arduino compatible bluetooth module
- bluetooth dongle for PC
- An android phone
Step 2: The Freetronics DMD
The dot matrix display I have used for this project can be found here
It features a 32x16 LED display, giving you a total of 512 high brightness LEDs to play with.
Two extra libraries are needed for the Arduino IDE, and these can be found here and here
You can check that your dmd is functioning properly by running the dmd_demo sketch found in the DMD library you will have just downloaded. Once uploaded to your arduino, connect it and the dmd with the link cable as depicted by the pictures.
Congratulations, your dmd is working correctly
Step 3: The Alarm Motion Sensor
Firstly the sensor is going to need a 12v DC power supply. Connect this to the positive and negative terminals that can be found inside the sensor, and switch on the power supply. The sensor will take up to 2 minutes before it is operational, as it performs a self check each time it is powered up. We will then need 2 wires to connect to NC (normally closed) and C (common).
Next set up the mini breadboard as shown in the diagram. Now, take the wire connected to the NC port of the sensor and connect it in line with the green wire on the breadboard. The wire coming from C is then connected in line with the red wire.
Finally, leaving the dmd connected as it was in the previous step, connect the wires from the breadboard as follows, Green to Pin 4, Yellow to Gnd, and Red to 5V.
And there we have it, all the hardware is in place and now we just need the sketch for the arduino.
Step 4: The Code
*Note: when programming the dmd this code must always be present, otherwise the Arduino IDE won't recognise your command
The sketch I have written for this project works by displaying a "startup" animation to the dmd, and then proceeds by reading the input from the sensor, displaying an open eye if the motion sensor is triggered, and a closed eye when not.
The sketch can be downloaded as an .ino file from here, or as text from pastebin from here
Usefully commands for the dmd include:
- dmd.writePixel(x,y, GRAPHICS_NORMAL, z) - turns on a signal pixel at coordinates x,y. The z value is either 1 or 0, for on or off
- dmd.drawLine(x1,y1,x2,y2, GRAPHICS_NORMAL) - draws a line from x1,y1 to x2,y2
- dmd.drawBox(x1,y1,x2,y2, GRAPHICS_NORMAL) - draws a box shape with a corner at x1,y1 and the opposite corner at x2,y2
- dmd.drawFilledBox(x1,y1,x2,y2, GRAPHICS_NORMAL) - same as above but the box is filled, not just the outline
Step 5: The Shield
Having got sick of unplugging and re-plugging masses of wires into my arduino each time I used it I decided to make a simple shield for it. Now all that needs to be done for this is to recreate the circuit from the breadboard, on the prototype shield. Simple stuff really. Just follow the (very poorly edited) diagram, using black wires for ground connections, red for positive connections, and yellow for data connections (if it is unclear in anyway feel free to ask).
Now, I have also included headers on the shield for a 7 pin bluetooth module. Whether or not I ever get around to adding bluetooth support for this project still remains to be seen, but for now it is there. (the pinout of your bluetooth module may well be different, so read the labels before connecting any old wires)
Step 6: Conclusion
Congrats! You now (hopefully) have you're own functioning motion sensing eye, all you have to do now is find somewhere to put it. I will be constantly updating this instructable with new animations and displays for the dmd as well as bluetooth and android support very soon! Suggestions are more than welcome.