As I mentioned in my last post, I was faced with the task of reprogramming the address on ten of my MinM LEDs. I had this program sitting around for doing that. You’d twiddle a global variable (the new address you want the MinM to have), plug in the single MinM, upload the program, and it would send a broadcast to set the address. This was just plain dangerous. If I had mistakenly had my entire MiniMe buss plugged in when this program was loaded into the Arduino, it would have blasted all 50 of the LEDs to that same address. Then I’d have to reprogram each one back. I decided to find a better way.
My solution was to make an interactive program. It’s my first, but it’s already proven super valuable. I can give it simple one-letter commands in the Serial Monitor, and it does my bidding. Here’s the usage:
The ‘t’ command tests that there’s a device present on all the expected addresses for my anthrolume hardware:
This conveniently points out that LED 47 is missing. Maybe it’s missing, or more likely plugged into the wrong four holes of its 8-pin header connector. There are easy commands for slamming the whole buss to a particular color, which is handy for measuring how much current the harness draws under different conditions.
So faced with my readdressing task, I added the “@” command, which lets me interactively write addresses. Since this test program already has the address-harvesting code in it, I made the @ command super-conservative. It checks to make sure there’s only one device responding on the buss before sending any commands to reprogram. And since it knows the address of the existing device, it doesn’t use the scary “broadcast” address anymore, avoiding the ugly blasting problem I mentioned above. This program is hella handy – I bet I’ll be adding commands to this thing a lot.