Water reflections on a roof

SimTV: Arduino Uno and RGB shield A simple method to keep burglars away from your home is a TV simulator. It's basically a device with some bright RGB LEDs showing color patterns that resemble those of a telly turned on. They are sold at many electronic retailers. However, some customer reviews say that the color patterns do not look very realistic, with some distinctive flashes and colors that are usually not to be seen on a regular movie. Besides that, the color patterns often repeat after about half an hour.

Actually, distinctive color patterns that repeat after a short time, are a major disadvantage. Experienced burglars might recognize the color patterns and figure out it's a TV simulator. This would rather be an invitation than a deterrent.

So, let's build a better TV simulator ourselves. It's also more fun than buying something ready.

The Idea

What do we actually see when we watch a telly from outside a room? Usually there are colors with a medium saturation, changing slowly while the actors move or the camera pans. And there are very few hard cuts in the hue or brightness when the scene changes, when there is an explosion in an action movie, or something like that.

We could simulate these effects randomly, but what would look more realistic than using a real movie as a source? The idea is to squeeze a real movie stream into a sequence of RGB colors that are small enough to fit into an Arduino Uno with just 32 KByte of flash space.

You say that's impossible? It isn't! 😁

The Ingredients

I used the following parts for the TV simulator. They are rather cheap and can be purchased in many electronic shops:

  • Arduino Uno
  • Velleman KA01 RGB shield. Any other RGB shield or a self-made solution should work as well, maybe with some minor modifications to the code.
  • RGB LED strip (12 V, about 7 W, Common Anode)
  • 12 V wall power supply for supplying the Arduino and the RGB LED strip (1 A or more)

Now just connect the RGB shield to the Arduino, and connect the LED strip to the RGB shield. That's all, hardware-wise.

Caution: The RGB LED strip is a very intense light source that can cause permanent damage to your eyes! Avoid looking directly into the LEDs!

The Software

You can find the source codes of the Arduino sketch and the movie converter in my GitHub repository.

The movie converter is written in Python and uses OpenCV. Basically, it converts an mpeg stream to a source code that can be included in the Arduino sketch. But there are also a few parameters you can toy around with to improve the result.

The next step is to compile the sketch and upload it to the Arduino. The movie should start playing back immediately.

Actually, the encoding is so efficient that you can cram a full-featured movie of 2 hours into the tiny Arduino memory.

Behind the Curtains

How does the converter work? And why is it so efficient?

First of all, as nobody is going to actually watch the simulated movie, we can remove the audio tracks and drastically reduce the frame rate. 10 frames per second is the default, but if the Arduino memory is too small for your movie, you can even go down to 5 frames per second.

Also, unlike a real TV, the RGB shield is only able to generate a single color, so all we need is the movie as a stream that is scaled down to a single pixel.

The converter software now analyzes the single-pixel movie stream. For soft color changes (like fixed camera positions or slow camera pans), it only stores the target color and the time it takes to reach it. When playing back, the Arduino will just gradientally change from the current color to the target color in the given time. For hard color changes (like jump cuts or in action scenes), the change to the target color will happen immediately.

Movies mostly have soft color changes, and only a few hard changes, so several seconds of video material can be stuffed into just a few bytes. This is why the converter is so efficient.

The algorithm is pretty simple, but gives amazingly good results. Especially on action movies, with a lot of cuts and striking action scenes.