Introduction: Fake TV - Burglar Deterrent
I was shopping around on Amazon the other day and came across a product that I thought was genius. It is called Fake TV and it acts as a burglar deterrent while you are away from the house. At night, the Fake TV turns on and uses a series of LEDs to project random colors that looks as though someone is inside watching TV when viewed through curtains or shades. There are some videos of it in action on YouTube and I have to say it really does look like someone is inside watching TV. This should scare off the large majority of petty thieves that are just looking for the quick opportunity. If someone is casing your house, this probably isn't going to help you though. See the commercial version here:
Anyway, they wanted $25+ for these things that are nothing more than a microcontroller and some LEDs. I thought about it and had the solution I am presenting here dreamed up in about 5 minutes. About 2 hours later I had a finished product using only left over bits I had from other projects. If you purchased these items you could likely build your own for under $10 too. My solution uses an AT Tiny 85 and Neopixels. You could easily swap in a full Arduino for the ATTiny, or swap in some transistors and LED's or RGB LED's for the Neopixels. It would only take very minor tweaks to the code.
This solution is better than the commercial product in my eyes because it is fully customizable! I even included a potentiometer you can use to adjust the brightness to get the exact effect you are looking for!
Step 1: Gather Your Parts
Here is my parts list:
- ATTiny 85 - 8 pin microcontroller - purchased mine from Jameco here
- 8 pin DIP socket - optional but helpful for future reprograming - purchased mine from Amazon here
- WS2812B RGB LEDs - aka NeoPixels (60 per meter) purchased mine from eBay, see detail below
- 10 uF electrolytic capacitor - pulled out of an assortment pack I purchased from Amazon here
- Resistor - somewhere between 300 and 500 Ohms will be perfect - pulled out of an assortment pack I purchased from Amazon here
- Hookup wire - helpful to have 3 colors, but not necessary - I think I got mine from RadioShack
- Perfboard - I prefer double sided with tinned holes, but you can manage with others - from Microtivity on Amazon here
- Barrel Jack - This is optional, you could solder your power supply directly to the device - purchased mine from Amazon here
- 10K potentiometer - Not necessary, but helpful for fine tuning the brightness to get the right look and feel - mine came in an Arduino starter pack but these on Amazon are cheap and should be perfect
- Power adapter - something between 3.5 and 5.5v. Or something with a higher voltage that you can step down with a voltage regulator - pick one of these up from a garage sale, your junk drawer, etc
I had all of these parts laying around from other projects but they are all easy to pick up at many online retailers. The only "high cost" item is the WS2812B LEDs. These are best known by the name NeoPixels as marketed by Adafruit. If you want to support Adafruit then go buy them from their website. I, however, found them for less than half the cost on eBay. I purchased my NeoPixels here. They have worked great on 4 different projects with no dead pixels or any issues whatsoever.
Power Adapter: You likely have several of these laying around the house that no longer serve their purpose or the item they powered has long since been lost/broken/tossed. I picked one up at a garage sale a few days ago for 25 cents to add to my collection. For this project you will need an adapter that will output somewhere between 3.5v and 5.5v. It needs to stay within that range when under load and when under no/low load. It also needs to be able to source enough current. The LEDs should consume a maximum of 60 mA per LED (20 mA per color). In my design this means I need 60 mA * 8 LEDs = 480 mA plus whatever the microcontroller consumes. I estimated that the ATTiny likely isn't consuming more than 40 mA for this application (pulled that guess out of thin air) so my total maximum current draw should be 520 mA. I had one laying around that stated it could deliver 4.8v @ 800 mA. I plugged it in and the voltage under no load was 4.95v per my multimeter. Be careful because this is not always the case, many times these power adapters can have near double the voltage at low/no load. This device covers a wide range of current draw which could result in a large fluctuation in voltage on some of the lower quality power adapters. Read more about power adapters on Adafruit's learning site here. One of the cheapest and easiest solutions is likely to pick up a cheap cell phone charger from the grocery store checkout isle, you know the pink rhinestone kind they sell for $2. Then power your device with an old USB cable you don't mind tearing apart. Those little adapters typically source 500 mA @ 5v and are regulated supplies. Or you can use a larger wall wart, batteries, etc and step the voltage down with a 5v regulator. Here is some info on those.
Step 2: Breadboard It With an Arduino
I suggest you breadboard everything before you start soldering. It is always nice to get the bugs worked out BEFORE you have soldered a single connection. With that, I also suggest, if you have an Arduino UNO or other full sized Arduino with headers for easy connections that you program and test the setup before switching over to the ATTiny, it is just much easier to work with.
I am going to show you this setup first with an Arduino Uno serving as the microcontroller. No pins need to be changed or reassigned in the code to make this work. You will see a few steps later that all we then have to do is pull out the wires leading to the Arduino and replace it with the ATTiny, add power supply, and you are ready to test the final setup.
For the purposes of breadboarding and the final build I like to use three colors of wire in simple applications like this. Red is always Vcc (Voltage high), Black is always Ground, Green is always Data. Those are the three colors of hookup wire I had available, you may prefer something else. Whatever floats your boat.
Place the components like I have shown in the Fritzing diagram above.
A little detail:
The potentiometer (orange looking plus) - This is acting as a voltage divider. It takes power and ground and as you turn it CW or CCW the voltage output on the top pin will change from supply voltage down to zero. What I have used is a 10K pot, you can use pretty much any value. This will output a voltage which will be picked up by our Arduino (and ATTiny 85) on A1. This will then be mapped to a max brightness value that will control the maximum brightness output by the device.
WS2812B (aka NeoPixels): Ignore the pins identified in the Fritzing diagram, they do not have WS2812B version. Instead recognize that 5v goes to the solder tab marked "5V" on the strip. Ground goes to "GND". Data is routed from digital pin 4 on the Arduino (also digital pin 4 on the ATTiny 85) through a resistor (between 300 and 500 Ohms) and to the tab marked "DI" on the strip. The capacitor is in place to help remove voltage spikes as pixels flash on and off. There is a great tutorial on these LEDs on Adafruit's website found here. IMPORTANT: If you are using only 8 pixels to create your Fake TV then you should be ok, the Arduino can source 500 mA via USB. IF YOU ARE USING MORE PIXELS you will need to provide an alternate power source for this part of the setup.
Plug the Arduino into your computer via USB. Nothing smoking? Great! Something smoking? BAD!
Step 3: Load the Code
If you have done everything correctly you should be able to just copy and paste this code (attachment) into your Arduino IDE and upload straight to the Arduino. Within seconds you should see the breadboarded prototype glowing in all its glory.
I am only a few months into coding so my code is likely very inefficient and could be picked apart by some of you out there that are far smarter than me. Feel free to comment with any constructive criticism regarding the code.
You will need the Adafruit Neopixel library. You can download it here.
Some points on the code:
In the main "void loop()" section the code is simply generating random colors, brightness and time delays in order to simulate the changing scenes that might be in place if you were watching TV.
The potentiometer setting determines what the maximum brightness of the Fake TV will be. Low brightness is already set. Brightness on the pixels varies from 0 (off) to 255 (full on). Each pixel consumes the most power possible when Red, Green and Blue are all maxed out at 255 and Brightness is maxed out at 255. This is full on, all white light and the pixels should consume about 60 mA each in this moment. Feel free to alter the code to generate a lower maximum brightness to keep your power consumption down if that is of concern.
A note about the colors: I initially had the colors set up to randomly generate values from 0 to 255 but I found that certain times you would get something like Red = 255, Green = 3, Blue = 10 which produced almost pure red light or at times pure Green or Blue. This just did not seem to mimic the TV look very well so I jacked the minimum color values up to 150 in order to get more subtle colors that were more "white" like you get out of an LED TV. Feel free to play around with this as you see fit.
Everything working? Play with the potentiometer and see if your brightness changes. If you are staring straight at the pixels, you may be blind by now. These suckers are bright!
Step 4: Program Your ATTiny 85
Ok, here is where I will gladly point you to other sources. This is really quite simple but does not warrant me rephrasing everything. I first messed around with controlling NeoPixels using ATTiny 85 after reading danasf's post "Use a $1 ATTiny to drive addressable RGB LEDs". It gives you a pretty good guide of how to program your ATTiny 85 for this purposed. It is based on work done by High/Low Tech in which they use your Arduino to program the ATTiny. There are also other solutions, but I liked this on the best.
Find more at High/Low Tech's pages:
Big thing here is to be sure to load the bootloader after selecting the 8 MHz INTERNAL clock. If you burn the fuses wrong it won't work. After you load the bootloader you just then upload the code I supplied and then your ATTiny is programmed and ready for your Fake TV device!
Move on to testing it on the breadboard.
Step 5: Return to the Breadboard - With the ATTiny 85
Now that your ATTiny is programmed you can return to the breadboard.
Pin 1 on the ATTiny 85 is marked with a small dot, arrange the chip such that you are looking at it with the dot in the upper left so you can follow along. Now take a look at the pinout diagram (courtesy of Sparkfun) in the pictures above and prepare to be confused if you are a newbie. The "physical
pins" count sequentially down the left side 1,2,3,4 with pin 4 being in the lower left. Then jump across to pin
5 in the lower right and count sequentially up the right side 5,6,7,8. Easy, right? Wrong. Those are the physical
pins, but what the microcontroller calls those pins for the purpose of programming is completely different. I
will save myself from typing it all out and just focus on the pins we will be using for this application (other than the programming).
Ground: Found on physical pin 4.
Vcc: "Positive" or your voltage high. Found on physical pin 8.
A1: Analog 1. Found on physical pin 7. Can also be assigned as digital 2, but we are using it to read the voltage from the potentiometer.
I/O 4: Digital Pin 4. Found on physical pin 3.
I know, I know, where do they come up with this stuff?? 3 is 4, 1 is 7 but sometimes 2... thank goodness someone already put this on a diagram, or my head would hurt.
Remove the wires from the Arduino, wire in your barrel jack or other power supply and connect to wires for power and ground to your ATTiny 85 and you should be up and running with your now shrinkified project. Your program should be working just as before and behaving nicely. Play with the potentiometer, make sure everything works. If so, you are ready to move on to soldering it all up to your perf board.
Step 6: Solder It All Together
Your layout may be different than mine. I tend to just sit down and start soldering without much forethought and planning. You may be more careful and meticulous than me. Either way, if you follow the Fritzing diagram from the previous step as your schematic, you should be all set.
If you break the pixel strip up into two or more pieces as I did, you will need to connect a wire from "DO" of the first strip into "DI" of the second strip. Follow the arrows as the data can only flow one direction.
I am not the best as soldering but here is my finished product.
Step 7: Plug It in and Test! You Are Finished.
My final product was small enough to fit in the palm of my hand yet bright enough to light up the whole room at max brightness. I played with the potentiometer to dial in the right brightness and took a look from outside. Looks like a TV to me. Overall this build from concept to finished product took about 3 hours. Now that you have the code and the layout you should be able to construct yours in half the time!
There you have it, your very own, fully customizable burglar deterrent. Plug this bad boy in when you are away and rest assured that the low level thieves will steer clear of your home. I would suggest plugging the power supply into a wall timer for full effect.
I intend to update this with more features as I have time.
Some additional improvements you may want to add:
- Real Time Clock chip to turn the device on and off at different times of the day/night.
- A second potentiometer or mode button to set a variable low level brightness.
- A reflective hood to channel the light more effectively
- A nice project enclosure or acrylic box.
- Integration into your Nest thermostat's away feature or home automation system.
Leave the comments, favorite it or follow me for future projects.