Posted: November 27, 2015 Filed under: Coding, Creations, DIY, Explorations, Getting A Clue, How-to, Pearls of Folksy Wisdom, So that didn't work | Tags: arduino, blinky, DIY, fastled, fire, glow, glowy, LED, LEDs, light, power
When doing an LED electronics project, there seem to be three big “P”s that have to be tackled:
1. Pixels (which ones, how many, what configuration?),
2. Programming (what do I want, and how can I do that?), and
3. Power (how much, from where, and how do I distribute it?)
And people (by which I mean: perpetual newbies like me) tend to do them in that order: first wire up some pixels, then program them, then figure out how to power it all for real.
And of course, this often leads to a problem where you get stuck between steps 2 and 3, where you have your creation sort of up and running on the lab bench — but now there’s this little problem of how to power it, and you have to go back and rethink and rework other parts of the project to accommodate the power situation. So it’s worth planning for power from the start — which is easy to say, but hard to do!
What could possibly go wrong? (A list)
So what happens if you don’t plan for power? Well, here are some power problems that I have personally had. How many of these can you diagnose just from the description? (“Failure to plan” is a nice catch-all phrase here if you get stuck.)
- Hrm, now how do I get power all the way up there?
- Gee, that’s a long run of wire… but if I use fat wire, it’ll be expensive and heavy and cumbersome. Nah…
- I’ll use skinny wire, it’s much cheaper… Hey, why is it only reading 4v at the far end? And does anyone smell something burning?
- OK, I switched to thicker wire, and I’ll just re-use the power connectors from before. Holy cow now the connectors are getting hot!
- Fine, I’ll switch to these big thick nonpolarized connectors. Huh, that’s odd, it’s not working now. Does anyone smell something burning?
- For this other wearable project, I’ll use a simple battery holder and regular alkaline batteries… hey… why are the colors so ‘warm’.. no blue? And now no green, too…
- OK, switching power to one of those ’emergency phone chargers’ that takes AAs and puts out 5v from a USB socket. Hey! Why are the batteries dying so fast?
- OK, fine, I’ll switch to this lithium battery pack… hey, it said 5000mAh… so why did it stop powering my 5000ma project after only half an hour?
- How come my WS2811 project works fine from my computer, but then flickers like crazy when I power it from this cheap USB wall power adapter?
- For this big outdoor project, I’ll use this big, burly 12V lead-acid marine battery. Hey… how come it won’t hold a full charge after the first time I let the lights go all night?
- Everything was working fine yesterday, before last night’s rain!
- Everything was working fine yesterday in the cold and snow, so it should be working fine today now that it’s warming up, right?!
- I think I’m going to switch microcontrollers. The old one had a power regulator that could handle 12v input. Hey… do you smell something burning?
- Why is this power switch getting hot now? And why is it now totally stuck in the “on” position? And … do you smell something burning… again?
So: Plan For Power.
The lesson to learn here is that for basically any real project, calculate and plan the power first. Before you wire up any pixels. Before you write any code. Just stop for a minute and think about how much power you’re going to need, and where it has to come from, and where it has to go.
Use on-line calculators that will help you figure out how much power you’re going to need, and what gauge wire you’ll have to use given how long your cable runs are going to be. I also really like the “LEDstimator” app for iOS to help explore some “what-if” values for things like wire gauge. https://itunes.apple.com/us/app/ledstimator/id945794010?mt=8
And above all else… uh… wait… do you smell something burning?
Posted: February 16, 2015 Filed under: Art, Coding, Creations, DIY, Explorations, That Totally Worked, Uncategorized | Tags: APA102, Apple, Apple //e, Apple II, AppleII, arduino, art, blinky, CALL -151, DIY, DotStar, fastled, glow, glowy, LED, LEDs, light, LPD8806, retrocomputing, WS2801
These days, I hack LEDs. I’m the co-author (with Daniel Garcia) of the FastLED library for driving tons of high speed LED pixels and strips using microcontrollers like Arduino and Teensy.
But back in the day, I hacked a lot of Apple II. I published a couple of shoot-em-up games (with Geoffrey Engelstein), all written in lovingly hand-crafted 6502 assembly language.
Finally I decided it was time to link the present to the past: to connect a hundred high-speed RGB LEDs to an Apple II, somehow, and ‘port’ our FastLED library to 6502 assembly language.
Well, I did it, and it works. My new creation, “FastLED6502”, can drive a hundred 24-bit RGB pixels at more than 30 frames per second from an Apple //e :
Here are the details of “FastLED6502”:
- “FastLED6502” is a lightweight port of FastLED’s core functions to 6502 assembly language for the Apple ][, Apple ][+, Apple //e, and Apple //gs.
- Supports APA102 / Adafruit DotStar LED strips, as well as LPD8806 and WS2801 (though those two are not fully tested yet).
- The LED strip is connected to the Apple II using the 16-pin DIP game port on the computer’s motherboard. The 9-pin DB joystick/mouse port on the back of the //c, //c+, and //gs cannot be used, as it lacks the TTL digital output signals needed to drive the LED strip.
- 24-bit FastLED Rainbow colors are included, along with FillRainbow, Random8 and a number of other useful functions from FastLED’s main library.
- Everything had to be re-written from scratch in 6502 assembly language. Luckily(?), I still remember how to do that.
- The assembly code knows the binary serial protocols for the APA102 (Adafruit DotStar), LPD8806, and WS2801 LED driver chips. Depending on which one you select, FastLED6502 transmits the LED colors in the correct protocol over the game port TTL digital output lines.
Considering that the Apple II sports a 1MHz 6502 so slow that even a “NOP” takestwo cycles, overall performance is pretty good: more than 30 frames per second for a 100-pixel strip.
Speaking of speed, or lack thereof, “three-wire” clockless LED strips such as the WS2811 NeoPixel are not supported now, nor will they ever be. The CPU is would need to be at least 20X faster to support them, and it isn’t. For that you want an Arduino or Teensy, and FastLED proper: http://fastled.io/
I gave the code its public debut at Veracode Hackathon 7. (The theme was “Cozy Cabin” — I don’t usually wear plaid.)
FastLED6502 at Veracode Hackathon 7
How’s it work?
So how does this all work? Well, you connect the CLOCK and DATA_IN pins from the LED strip to a couple of pins on your Apple II’s DIP game connector port, add power, and you’re ready to go. The Apple II’s game connector not only has inputs for joysticks, paddles, buttons, and so on, but it also has a few digital outputs — and that’s what FastLED6502 uses to deliver signals to the LED strip. On all the 16-pin DIP Apple II game ports (except for the //gs!), there’s even one pin that delivers a super-fast digital pulse; pin 5 is the C040STROBE line, which can pulse twice as fast as the other digital outputs. If you choose that for your CLOCK pin, the FastLED6502 code automatically shifts into high gear, and you get faster performance. FastLED proper does this, too, in a much fancier way; it’s amusing that ‘little’ FastLED6502 does some of this, too.
The code is in the “extras” directory here (and eventually on FastLED’s main branch, but not yet)
This is Crazy
Overall, this bit of code is completely nuts, and we don’t expect anyone to use it. At all. Ever. Accordingly, we’re not going to really support it, either. At all. Ever. It was a labor of love and a creation of pure modern retrocomputing insanity. But here it is, in all it’s insane glory, “FastLED6502”.
And now, if you cut me, I’ll bleed 16,777,216 colors at thirty frames a second.
Posted: May 25, 2014 Filed under: DIY, Explorations, How-to, That Totally Worked, Uncategorized | Tags: blinky, DIY, glow, glowy, invention, inventions, LED, LEDs, light, throwies, toys
At the last “HacKidThon”, we showed a passel of kids how to make LED “throwies”. Each one is a nothing more than an LED, a coin cell battery, and a magnet so the contraption can stick to metal surfaces, walls and buildings, and hang there glowing.
This week, someone asked me if we could modify the classic design somehow so that the LEDs could be attached to lanyards, instead of magnets. We wanted it to be as cheap and easy as the rest of the “throwie” recipe.
A little brainstorming with Eleanor, and we came up with this: plastic-coated paperclips!
The paperclips actually help hold the LED leads in place; we put tape around them as usual, though that’s not shown in the picture. The plastic coating keeps the paperclip from shorting out the positive and negative battery terminals.
The coated paperclips cost less than a penny apiece, and come in colors that match the LEDs. Victory!
Posted: April 4, 2014 Filed under: Art, Coding, Creations, DIY, Explorations, How-to, That Totally Worked | Tags: arduino, art, blinky, DIY, fastled, fiery, fire, glow, glowy, LED, LEDs, light
I’ve built and programmed a couple of different ‘fire’ simulations for Arduino and LEDs, and I’ve had numerous requests over the years to share the source code. I’ve always been happy to share my work; the holdup has been that before I share my code for the world to peer at, I like to clean it up a little. I like to give the code a clean shave and scrub under its fingernails before it steps out onto the wide open Internet where it might have an audience with Her Royal Majesty, The Queen of England. It could happen.
Anyway, I finally cleaned up the code for one of my simplest and most legible ‘fire’ simulations, and I give it to you, your Majesty, and everyone else, too. Here’s a video of the code in action on a 30-pixel strip of WS2812B LEDs (or maybe WS2811) and an Arduino. Source code link is below the video.
Full source code is here: http://pastebin.com/xYEpxqgq The simulation itself is only about 25 or 30 lines of code. It uses our (open source) FastLED library to drive the LEDs.
Discussion about the code and how to port it and use it are here on the FastLED discussion group on G+ https://plus.google.com/112916219338292742137/posts/BZhXE4cqEN4
Posted: July 3, 2012 Filed under: Creations, DIY, Explorations, That Totally Worked | Tags: arduino, blinky, creations, decor, DIY, glow, glowy, LED, LEDs, light, RGB, sculpture
After months of work, “Five Elements”, my first full light sculpture debuted this weekend at a private event. This quick video shows a short clip of each ‘element’; the actual five-element cycle is 12 minutes long, repeating each of the five elements five times each hour. As with any “version 1.0”, I have a dozen ways I’d like to polish and keep improving it, but I’m happy with it as is, too.
It’s illuminated by 150 RGB LEDs and controlled by an Arduino Uno using the FastSPI_LED library and my own custom code.
The installation at the debut event used a very different diffuser which made the LEDs more visible. While both were good, I think I prefer this diffuser overall.
Posted: May 1, 2012 Filed under: DIY, Explorations, That Totally Worked | Tags: 12V, blinky, DIY, electricity, glow, glowy, light, off-grid, power, repair, solar, solar cell, solar cells, solar panel, solar panels
I gave a “learning lunch” presentation on Small Scale Solar power today. We had a great audience, got great questions, and had fun doing it — despite the definite lack of sunshine to play with today.
The Short Version is this:
- Hook a solar panel to a charge controller to a battery. (There are starter kits with everything.)
- Presto: 12 Volt DC power!
- Use your newfound power as-is, or step down to 5v USB, or up to 120VAC using an inverter.
The slides don’t tell the whole story by themselves; that requires my own personal song and dance routine. Nevertheless, here they are, with “lite” graphics for fast download: PDF.
Posted: April 19, 2012 Filed under: DIY, Explorations, That Totally Worked | Tags: blinky, DIY, fix, garden, glow, glowy, LED, LEDs, light, nail polish, repair, solar, solar cell, solar cells, yard
Solar LED garden lights are everywhere these days, and by ‘everywhere’ I mean ‘in our yard.’ We’ve had some for a few years now, and simply through exposure to the elements, the plastic that covers the solar cells becomes so opaque that only a small amount of light gets to them any more. With the solar cells deprived of even that meager light that we get in Massachusetts in the winter, the solar cells don’t recharge the battery, the battery doesn’t power the LED, the LED doesn’t light up, and our yard has a serious bling deficiency. Eleanor and I took our solar garden lights inside to see if we could make them bright again somehow.
My first thought when confronting the frosted-over plastic was to try to ‘polish’ it with a fine-grit sandpaper. I had 400-grit handy and tried it on one cell, the bottom one in this picture. The top shows how weathered the cells were to start.
The sanding helped a little. Then I rinsed the sanded plastic dust off with water in the sink, and while it was wet it looked great, but as it dried it became frosted and opaque again. Thinking that perhaps we could use a mild plastic solvent to ‘polish’ the rough surface, I dabbed the solar cells with acetone, but again, as soon as it dried, the surface went from clear to cloudy again. “We need some way to keep it ‘looking wet’ even when it’s dry,” I mused. Eleanor got a wide-eyed LIGHTBULB! look in her eyes, and grabbed a bottle of clear nail polish! She applied a few test swatches.
The nail polish made the weathered old solar cells crystal clear again! I held the lights while Eleanor applied an even coat of nail polish to all the solar cells. It really didn’t matter whether the cells had been sanded or not, so we didn’t bother.
A few minutes later, the polish was dry, and we planted the lights outside again. You can see how completely clear the solar cells are. Our only concern was that the nail polish might block the UV light that provides a good portion of the solar energy to the cells.
We waited for twilight to fall, and when we checked the lights: success!
Even though it was mid-February the solar cells were now getting enough light to make the LEDs glow brightly! The solar cell rejuvenation project was a total success, and once we figured out how to make the cells ‘clear’ again, it was a quick and easy.
So what did we learn? We learned that ‘frosted’ plastic reflects precious light away from the solar cells; clean, clear solar cells can capture much more light. Clear nail polish is perfect for rejuvenating plastic-covered solar cells that have become weathered and dull. Some of the solar garden lights they sell have glass covers, and we speculated that they probably (1) are much more resistant to weathering, and (2) probably should be ‘cleaned’ differently from the plastic ones. Sometimes you need to try one thing to find out what you need to try next. Sometimes restating the problem out loud to someone else can give them new ideas. During the dim, dark Massachusetts winter, having bright, cheery little lights in the yard is great.
Posted: March 14, 2012 Filed under: Explorations, So that didn't work | Tags: blinky, bubbles, gitd, glow, glowy, light, soap, STDW, toys
The other day I was in the store and my attention was caught by “Super Miracle Bubbles® GLOW FUSION™ Bubble Solution” — bubble soap that claimed that it made bubbles that glowed. These were not bubbles that glowed-under-black-light (fluorescent), not bubbles that glowed-in-the-dark (phosphorescent), but actually bubbles that glowed-of-their-own-accord (chemiluminescent), or so the package claimed. $3.99 later, I was the proud owner of a bottle of this magic elixir.
Later that night, well after dark, Rosa and I carefully followed the instructions, adding the two included packets of “activator A” and “activator B” to the bubble soap, and stirring (not shaking!) for a minute. Lo and behold, the little bottle began to glow bright orange, like the innards of a glow stick!
Excited, we dipped the wand in the glowing solution, and blew some bubbles! In the cold, dark, winter night, they looked like this:
We tried and tried, and sure enough, after a while from the right angle, for a fleeting second, you could see that the bubbles had a tiny glim of light. But in practice, the drips of bubble solution that fell on the ground far outshone the bubbles themselves, and the full bottle itself was the brightest thing around. There was no hope of getting enough light out of it to photograph them.
The directions (inside the package!) point all this out. They tell you to cover the (clear) bottle with black tape or a black bag, and to let your eyes fully adjust to the dark to see the glowing bubbles. Any other nearby light will drown out the few photons escaping from the bubbles themselves. Also of note: the instructions repeat several times that these are for outdoor use only.
So, do they glow? Technically, yes. Practically, no. You cannot get a good, satisfying, “glowing bubble” from this bubble solution. On the other hand, it is pretty nifty to have a bottle of bubble solution that’s glowing in your hand while you’re blowing bubbles. Fun? Kinda. Worth $3.99? Not for regular use. Worth trying once? Yep, and I’m glad we did.
Updated April 4, 2012: Here’s a video of some Occupy folks experimenting with adding the contents of a chemical glow stick to some bubble soap. They got more or less the same results I did, but by a different route. Clearly, we need some SUPER glow chemicals…