Saturday, April 6, 2019

Tesla Coil Video

First post in a few years! Life got a bit busy. I think I'm going to be primarily focusing on video posts, and this is my very first foray into that.

Sunday, November 15, 2015

Halloween "The Sims" costume with color changing LEDs

This year my girlfriend and I wanted to make a The Sims costume for Halloween. We took a few pics of the build process for anyone else that might be interested in making one.

The basic idea was to make a sort of lamp-shade in the shape of the diamond (known in the Sims world as the "Plumbob"). This would slide over a clear acrylic tube with some LEDs inside to hold it up.

We debated for a while about what materials to actually use for the "lamp-shade". Here were some thoughts we had about the following:
  • Cut out acrylic triangles and glue them together. Seems like it would require very precise cutting to get everything to fit together without gaps.
  • Wire-frame using wooden dowels held together using glue. Probably could have went this route, we were unsure about using wood glue which needs to be held in place for a long time to set. However using wooden dowels and hot glue probably would have been fine.
  • Wire-frame using some metal coat-hanger like material and solder together. We decided to go this route because soldering is relatively quick and strong. And we could strengthen the joints afterward with an epoxy.
Some other thoughts:

Soldering vs Sugru? - Sugru might have been the best way to go about it since you can easily hold everything in place while the Sugru is still soft.

Paper vs Fabric? - Fabric seemed more durable but more time consuming. Also the cotton we bought didn't actually seem to diffuse light as well as regular paper, but it turned out to be okay. In the end we went with cotton mainly due to the durability.

Okay, without further ado, the build photos:


Cutting the 0.062" steel rod stock I bought turned out to be a nightmare. I had to resort to using my rotary tool and a cutting wheel to cut through it

Tacking the pieces in place and soldering. These were about 3" in length. Using lots of rosin flux (the gross looking Q-tip is flux, I swear!)

Finished soldering the base piece together
Soldering the side pieces. These were about 7" in length. It's very helpful to have an extra hand at this point! Starting off with 3 at a time so that the tip will be centered.

The rest of the side pieces soldered and the tip soldered.

Same process to solder the side pieces for the bottom, but more annoying because it doesn't lay flat on the table anymore. Lots of helping hands needed for this one! Started off by holding 3 in place then soldering the other 3.

Wire-frame almost complete. A hole still needs to be cut on the bottom.

Soldered some smaller pieces near the tip so it can be cut off without losing its strength. In hindsight we should have done this before the bottom was completed so it could sit flat on the table. Lots of goopy rosin flux.

Since we were making two, I learned from my mistake and soldered the bottom support pieces on the first half this time. This one was a bit uglier because the support pieces went around the outside versus in between the side pieces, but it actually ended up breaking fewer times, so I suppose it was stronger.


Time to cover it in fabric. The hot glue actually wouldn't stick very well to the smooth steel rods. We ended up creating small folds and hot gluing the fabric to itself with the rods in between for a strong connection.
We decided to use white fabric because we wanted it to show equally well for green, yellow, and red like in the game.

First piece glued down.

Shorter side glued down.

Rotate and repeat for the top piece, ensuring that the fabric is pulled taught throughout the process, but not too taught that it breaks the joints. This was probably one of the most frustrating parts of the build.

Starting on the bottom half.

Magnets were helpful to hold the fabric in place while gluing. For the bottom half, the fabric is just glued flat onto the top half (doesn't wrap around the rods).

All covered up!


The electronics were the easy part of this project (but I might be a little biased). The plan was to use the ws2812 "neopixel" LED strips that I already had on hand and a Teensy-LC as the controller, all powered from a 5V USB "mobile charger".

The LED strips need a 5V power supply. I simply made connections to the Teensy Vin/VBUS/5V and GND pads. If you're using many more LEDs you won't want to share the same wires to power both the Teensy and the LEDs (in this case the USB cable), but for the 16 that I used I didn't have any issues.

Connections to the Teensy-LC

There is only 1 signal that is needed to connect the Teensy to the LED strip, and that is Pin 17 on the Teensy-LC. This pin has a 3.3V to 5V level shifter which may be required for some LED strips to work properly, although mine works with 3.3V levels just fine.

Take note that the LED strips are "directional" in that one set of pads is for an input, and the other for an output. These are indicated by arrows. The Teensy-LC should be connected to the input side, and if daisy-chaining strips together, the output of one strip should connect to the input of another.

Connections to the LED strip. Note the direction of the arrow

I was able to put two strips back-to-back and solder the pads directly to each other. My strips came with a "weatherproofing" jacket that I kept on to prevent the pads from shorting to each other on the back sides.

Strips soldered back to back
 The complete system. The Red block is the USB charger.

Some hot glue at the bottom for strain-relief


You can find the code at

I used the "FastLED" library that came installed with Teensyduino. This made it pretty simple to set up the LEDs and make smooth gradients from Green to Red without doing all the interpolations myself.

The code I set up is a very simple state machine with 4 states:
  • State 1 - Keep the plumbob green for 15 minutes.
  • State 2 - Transition from green to yellow to red. This takes 2.5 minutes.
  • State 3 - Keep the plumbob red for 2 minutes.
  • State 4 - Transition from red to yellow to green. This takes 2.5 minutes. Return to state 1
The FastLED library uses a number from 0-255 to control the Hue of the LEDs. Red is 0, and green is 68. If you know how long you want it to take to transition from green to red, you can easily figure out how long you need to pause before incrementing or decrementing the color. In my case, we wanted it to take 2.5 minutes, so each increment should take approximately 2.2 seconds.

Holding it up and finishing touches

We were thinking about creating some sort of harness to hold the whole thing up, but in the end, we just shoved the thing down our shirts. For the ladies, a bra helps. For the guys, I used some shoelaces tied around my body to support the thing. A taut line aka midshipman's knot worked much better than a typical square knot to keep the shoelaces tight in place.

My girlfriend also made some cardboard props from the game to go along with it!

End Result

It actually ended up looking pretty good! We won some prizes at a costume contest at a bar, but ended up losing 2nd place to Daft Punk.

Some interesting observations from throughout the night:
  • People either LOVE the costume, or have no idea what it is
  • Walking around with these definitely draws a lot of attention
  • You'll be able to spot yourself in party photos no matter how many people are in the crowd
  • You'll never find yourself in the dark
  • After taking these off, your brain will start to see a weird green tinge to everything for a few hours

Wednesday, July 1, 2015

Hardware Files Now on GitHub

I finally started using Git for my hardware files as well as the software files. You can now find all the schematics and PCB project files for my LED Heart and Digital Clock on my Github page. The files are in Altium Designer format, but I have also included a PDF output and Gerber outputs for the PCB.

Saturday, May 16, 2015

Using a PS3 eye toy with OpenCV

I was looking for a USB webcam that I could use for doing some openCV/digital control systems projects. The PS3 Eye seems like a great product for this!
  • $7 on Amazon!!
  • Standard USB interface
  • 640 x 480 resolution. Not great but...
  • 60 fps framerate, up to 120 fps with lower resolution (320x240)
  • Did I mention...$7?!

So I tried this out with a simple program I wrote in OpenCV, and after actually writing a frame-rate counter I realized that I actually wasn't running it at 60fps! Hmmm. Turns out you need to do a little bit of work to get the settings just right.

Video for Linux (libv4l2

You can get access to the more advanced features of camera by using a library called video for linux. On ubuntu, I installed an application called qv4l2 and all the necessary dependencies. It looks like this(when I first start it up, it shows my video0 device, which is my laptop's webcam)

Now, you need to open up the PS3 Eye. Usually this is under the device /dev/video1:

The "open file" dialog is a little strange because it doesn't show the device until you acutally type in the full name.

Once the PS3 Eye is open, you have access to all the settings that can be changed through the USB protocol! In addition to the screen above, there are more parameters that can be changed:

Manual exposure and gain are especially handy if you're trying to track some objects and you don't want the camera to be adjusting the brightness/contrast if bright objects are entering the scene. Also, a darker exposure will have less motion blur, and a lower gain will have less grain/noise, at the cost of brightness.

Here are some examples below from my tests waving a laser around:

Auto exposure, 30fps

60fps, manual exposure

Using the Eye with OpenCV

On my system using Ubuntu, I didn't need to do anything special to get the Eye to work with OpenCV. I just needed to pass the video device ID (in my case 1) to the command.

The exposure settings and the framerate can be changed from qv4l2 while your openCV app is running. However, you can also have your openCV app change the settings directly. Additionally, some settings, like the capture frame size cannot be set in qv4l2 while openCV is running.

The VideoCapture object in OpenCV has the method set(propID, value) which lets you change any of the settings above. However, I've had trouble actually getting it to work. I have read something about needing to compile openCV with v4l2 support, so I am going to give that a shot.

Sunday, April 26, 2015

Waterfall audio visualization

So it's been a while since I've posted. I didn't realize I had not posted my favorite LED visualization so far, a "waterfall" display.

Currently I am still using an ATmega48 to control the LED strip, and a basic FTDI cable to talk to the ATmega. In the future I would like to use a teensy and the ws2812 library in order to control more LEDs.

More to come...

Monday, October 6, 2014

Code for Audio Visualizations

I finally got around to cleaning up the code to my audio visualizations a bit and publishing it on BitBucket.

If you're interested, you can find it here:

Saturday, August 23, 2014

Wine Bottle Digital Clock

Circuit board done in Altium Designer. Took me a year to finally decide how to house the giant displays.

Will upload schematics/gerbers/code eventually.