April 30, 2013
Minecraft Ore-Block night-light
You can buy a minecraft ore-block night-light... but it's more fun to make your own, and this one is not just redstone. It cycles through the colors of redstone, emerald, lapis lazuli, iron, gold, and diamond. It also pulses slowly; just a subtle fading in and out. My son and my nephew both had birthdays this month; although they're past the age of needing nightlights they're both minecraft nuts so I decided to make these for them.
Let's start with the light. For the light source, I used a 10mm RGB LED from Adafruit. This common-anode RGB LED provides a nice bright color-space, and the diffused package mixes the light well. I first wrote a quick Arduino program to read three potentiometers and adjust the red, green, and blue levels according to those pots. The program would then send the actual RGB values back to the computer via the serial line. This allowed me to experiment with different light mixes in an effort to find the best RGB combination for each color. I could tweak each knob, see the results immediately, and when I found a combination I liked I could check the serial line to see what it was.
Here's the program, and here's what the test-rig looked like:
I eventually decided on these tuples for each type of ore:
Redstone (255,0,0)
Emerald (0,255,0)
Lapis Lazuli (0,0,255) --- those three are easy!
Iron (16,4,0) --- closest I could get to "brown" with the RGB!
Gold (255,115,0) --- maybe a bit less green?
Diamond (0,255,100) --- could've gone more blue, but this works.
These colors are hard-coded into the program, which was downloaded onto the microprocessor before soldering the microprocessor into the board. Here's the program.
Next, the electronics: I chose to use an ATtiny84 microprocessor to drive the light. The ATtiny84 has much more memory than necessary for this purpose, but I needed three separate PWM outputs to do the color mixing (so the ATtiny45 was out) and I didn't have any ATtiny44's handy. The board layout was fairly simple: I used EAGLE CAD, and here's the design:
The EAGLE files are available here. I created the board using toner-transfer and FeCl etching.
Next, it was time to make the physical ore-block. I used 1/4" clear acrylic, cut on my table saw. The sides are each 3" high by 2 7/8" wide, and the top is 2 3/4 x2 3/4. I then used a router table to cut a 1/8x1/8" shoulder-groove around each piece.
The side pieces then fit together, each overlapping the next. The top fit perfectly inside the recessed square formed by the sides. The bottom was left open for the moment, but if you're following along on visualizing how this goes together, you'll realize that there is a 2 3/4x2 3/4" recessed square hole there, too --- just the right size for the circuitboard.
Before gluing the pieces together, I sandblasted them ---both sides--- to make them better diffusers.
I then solvent-welded them together using methylene chloride. Plastic model glue would have worked nearly as well, but I work in a building with chemistry labs and fume hoods and solvent-welding acrylic works REALLY well. When finished, I had a nice translucent 3" cube of frosted acrylic, open on the bottom. I also drilled three holes near the bottom of one side of the block; holes that would later accommodate the buttons and power cord.
The outside pattern is key to making this a Minecraft block, of course! I created a single 3x3" side using a vector graphics program, then put five sides together so I could wrap them around the cube. The largest-format laser printer I have available will only print letter-sized paper, so I had to break the wrap into two pieces, like this:
The top piece wraps around three sides of the block, and the bottom folds over the top and fourth side. The extra on the sides wrap around to prevent light leakage around the edges. Here's a link to a .pdf of that design, should you want to make your own block.
To make the "stone" parts of the lamp light-proof I used 3M spray adhesive ("Super 77") to glue a print of this pattern onto a smooth piece of aluminum foil. Next, I carefully cut the pattern out using a sharp new X-Acto blade and a metal straightedge.
I then carefully creased this aluminum-foil/paper label on all fold lines, using the metal straightedge again. I sprayed the aluminum side with adhesive once more, and wrapped the label around the block.
The final assembly step was to provide a power source (salvaged 5V phone charger) and solder the power cord and buttons. I found two buttons that were nearly identical; one was momentary and the other latched. The latched button is used for power, the momentary button cycles through ore-type. The circuitboard fit (with a small amount of sanding) into the recess on the bottom of the cube: I glued it into place with RTV and added four stick-on rubber feet.
It works great, the boys think they are cool, and it's on to the next project: writing a final exam for my electronics course!
April 8, 2013
ISP Clip for ATtiny44/84 (or others!)
I got my start in microcontrollers with the Arduino, as many of us outside of electrical engineering did. (And still do!) The ease of programming that little board makes it a great gateway... and like any gateway, sometimes you go through.
Most of my projects now don't use Arduinos directly. For simple microcontroller applications, it's much more cost-effective to use a bare microcontroller selected for the memory size and pin-count you need to do the job. For me, that usually means either the 8-pin ATtiny45/85 or the 14-pin ATtiny44/84. Both can now be programmed directly using the Arduino IDE with either a commercial programmer or with an Arduino, as described on the excellent MIT High-Low Tech site.
One frustration with these smaller microprocessors, though, is that I either had to take them out of the circuit and wire up a breadboard as shown at MIT's site, or build a 6-pin ISP connector into my project. I built a 6-pin ISP-to-breadboard adapter assembly, which often helped during the prototyping process, but it was not ideal. What I really wanted was something that would clip directly to the chip and let me reprogram it without removing it from the breadboard or circuit.
It turns out the solution had been sitting in my toolbox for the last 15 years, I just didn't know it! Years ago, someone gave me a set of "DIP clips": they're a spring-loaded clip made by 3M that grabs a DIP chip from the top and provides easy contact points to each pin. They're still sold here and elsewhere. I glued a 6-pin ISP header on the side of one of these with wires from the ISP header to the appropriate pins on the clip, and voila! A ISP clip.
This one is for the ATtiny84 (or 44): I just plug my ISP programmer to the clip and put the clip on the ATtiny84: I can then test and debug the microcontroller while it's in the circuit —even if it's soldered into the circuit— without having to build an ISP header in the circuit. There's another 8-pin clip that does the same for me with the ATtiny85 (or 45).
New idea? No... Pretty? No... But it works nicely.
Most of my projects now don't use Arduinos directly. For simple microcontroller applications, it's much more cost-effective to use a bare microcontroller selected for the memory size and pin-count you need to do the job. For me, that usually means either the 8-pin ATtiny45/85 or the 14-pin ATtiny44/84. Both can now be programmed directly using the Arduino IDE with either a commercial programmer or with an Arduino, as described on the excellent MIT High-Low Tech site.
One frustration with these smaller microprocessors, though, is that I either had to take them out of the circuit and wire up a breadboard as shown at MIT's site, or build a 6-pin ISP connector into my project. I built a 6-pin ISP-to-breadboard adapter assembly, which often helped during the prototyping process, but it was not ideal. What I really wanted was something that would clip directly to the chip and let me reprogram it without removing it from the breadboard or circuit.
It turns out the solution had been sitting in my toolbox for the last 15 years, I just didn't know it! Years ago, someone gave me a set of "DIP clips": they're a spring-loaded clip made by 3M that grabs a DIP chip from the top and provides easy contact points to each pin. They're still sold here and elsewhere. I glued a 6-pin ISP header on the side of one of these with wires from the ISP header to the appropriate pins on the clip, and voila! A ISP clip.
This one is for the ATtiny84 (or 44): I just plug my ISP programmer to the clip and put the clip on the ATtiny84: I can then test and debug the microcontroller while it's in the circuit —even if it's soldered into the circuit— without having to build an ISP header in the circuit. There's another 8-pin clip that does the same for me with the ATtiny85 (or 45).
New idea? No... Pretty? No... But it works nicely.
Subscribe to:
Posts (Atom)