Advertisements

82°

This is a 100% recycled yak fur story.

Molly asked me a thoughtful question while I was in the middle of something else and I said “Just a second, I need to rotate my brain.”   A moment later, I said OK and she asked me if my brain was all rotated now.  I replied, “Well, 82° out of 90°, close enough.”  Molly quipped “And since when did you ever do things square?”

But then I nerdsniped myself.  I started to wonder about 82° angles.  If a polygon with 90° angles is a square, what sort of polygon do you get if you turn 82° at each corner?  It’s not one of your basic shapes, because:

  • 120° angles make a triangle (3 sides, since 360° ÷ 120° = exactly 3)
  • 90º angles make a square (4 sides; 360° ÷ 90° = exactly 4)
  • 82° angles make a ??? (?? sides; 360° ÷ 82° = 4.3902439024???)
  • 72° angles make a pentagon (5 sides; 360° ÷ 72° = exactly 5)

It must be some kind of … star shape, 82 doesn’t go evenly into 360, which means that you’d have to spirograph-around the circle more than once to come back to where you started.

But what kind of star?  How many points would there be on a star with 82° angles at each point?  I decided that I had to know, and that I wanted to see what the star looked like, not just find out the numeric answer.  The numeric answer is the GCD of 82 and 360, and I could figure that out, but then where’s my picture of the star?  I decided to write a quick program to draw stars with angles of  ‘N’ degrees at each corner, and to print out how many points there were on the star.

And what’s a quick way to write a program to draw connected lines at various angles?  With Logo and turtle graphics, naturally.  Luckily, I’ve already done some programming in Logo.  Unluckily, it was back in the 1980s.  But it’s like riding an (imaginary) bicycle, right?  I was sure I could remember and pick it up again quickly.  I also (correctly) guessed that there were probably Logo interpreters that ran in a web browser using Javascript.  I chose this one, because it had handy examples and Logo language reference documentation built in: http://www.calormen.com/jslogo/

jslogo.png

So ten minutes later, I had refreshed my Logo skills.  Luckily, Logo is secretly sort of a dialect of LISP, and I’m very comfortable with LISP-like languages.  Here’s the code I finally came up with:

to anglestar :angle
  clearscreen 
  penup 
  forward 150 
  pendown

  make "count 1 
  setheading :angle

  while (heading > 0) [ 
    forward 200 
    right :angle 
    setheading round modulo heading 360 
    make "count sum :count 1
  ]
  forward 200 
  show :count
end

anglestar 82

Now experienced, professional Logo authors will notice that there’s a ’round’ in there.  Why is that?  If all these numbers are integers, why do I need to ’round’ the numbers at all?  Well, I didn’t have it in there at first, and the program wasn’t stopping.  At all.  It’s because this particular implementation of Logo, in Javascript, uses Javascript floating point numbers for Logo numbers, and since “modulo” is a floating point division-remainder operation in Javascript, sometimes instead of coming back with an answer like 377 modulo 360 = 17, it was really doing something like 377.0 modulo 360.0, and coming back with an answer like 17.000001, because floating point math is way more complicated and hard that you might think.  So after having this problem, and fixing it by inserting a ’round’ into the heading math, everything worked better.  Here’s the output from N=82°

82crop.png

And it printed “180”, meaning that this is a 180-point star.  Or, as Molly pointed out, more of a bike wheel than a star really.  An imaginary bike wheel.

I decided to try other angles since I now had this great program.  With N=80°, you get a nine-pointed star, because 80° x 9 = 720°, which is twice around the 360° circle:

80crop.png

And with N=81° you get a 40-pointed star:

81crop.png

Although as Molly pointed out, this one isn’t really a ‘star’, either.  This one is more of an imaginary bicycle gear, a lot like this real 40-toothed bicycle gear:

So anyway, the answer to the original question, “How many points are there on a ‘star’ whose lines meet at 82° angles?” is …. 180.  (And yes, the GCD of 82 and 360 is, in fact, 180!)  But to figure it out my way, I had to refresh my 35-year-stale Logo skills, debug and code around a Javascript floating point math issue, and now the floor is totally, completely covered in yak fur.

Oh, and after all this, Molly very patiently re-asked me her original question again, and I answered her without yak-further delay.

 

Advertisements

Cautionary Tales of 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?

 


Lanyard-mountable LED throwies

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!

20140525-203924-74364191.jpg

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!


Fire2012: an open source fire simulation for Arduino and LEDs

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

Enjoy!

-Mark

 


Running 2 Amps of LEDs through an Arduino Nano

The Arduino Nano provides up to 0.5 Amps of regulated +5v output, on it’s “+5V” pin, which can drive between 10-30 addressable LEDs, depending on your chosen brightness and animation patterns.  Even if you connect a 2 Amp USB power supply (e.g. an iPad charger), the Nano’s little voltage regulator will overheat if you try to draw more than 0.5 Amps from the “+5V” pin on the Arduino.

However, you can ‘tap’ the pre-voltage-regulator power traces on the Nano’s circuit board, and drive 2 Amps of LEDs (over 100) ‘through’ the Nano, and do it in a way that keeps your wiring simple.  Basically, you can find the places on the Nano’s board where the raw USB power connections are exposed, and tap into them there.

WARNING!  
MODIFY, MISUSE, AND DESTROY YOUR ARDUINO AT YOUR OWN RISK!
DANGER! FIRE! RUN! 

But, OK, if you wish to continue…

1. Flip the Nano over so you’re looking at the bottom side.

Two Amp Arduino Nano

2. The unfiltered, unregulated +5 signal from the USB port is available on the board near the base of the D2 pin.  Carefully solder a wire (red, for +5v) directly to the exposed component pin on the circuit board.

3. A convenient companion GND connection can found on the center pin of the power regulator itself.  Solder a wire (black, for ground) to this pin.

4. By powering your LEDs from these direct-power traces (and thus directly from the USB power source), instead of through the Nano’s half-amp-max voltage regulator, you can drive up to about two Amps worth of LEDs, provided that you plug the Nano into a 2 Amp USB power adapter.

I’ve used this technique in probably six or eight Arduino Nano projects, and nothing’s caught fire (yet).  With a little probing around, you can also find similar ‘hacks’ for other models of Arduino, e.g., the Uno, Leonardo, etc., but since power is handled differently on each board, you’ll have to figure it out differently for each board design.

Good luck!


Hoop skirt — made with real hoops!

Eleanor and I spent this weekend working on her Halloween costume.  Part of what she planned was a ‘hoop skirt’, but as you can imagine no commercially available hoop skirt met her exacting standards of design and quality — and also my exacting budgetary requirements.  Naturally, we decided to take the DIY route!  And, we pondered, what goes into a hoop skirt? HOOPS, obviously!

We picked up a used dress at The Garment District (our local vintage/costume/cheapo clothing mecca), a set of three hula-hoops, and some leopard-print duct tape.  The smallest hula hoop became the bottom (largest) hoop for the skirt; the other two had to be dramatically resized smaller (via pliers, dremel, duct tape).  We started construction from the waist down, with a nylon web belt with a parachute snap buckle.  From there, we hung each hoop with repositionable blue painters tape, and balanced each one until it was level.  Then Eleanor secured each hoop in place at the right height with duct tape.

And presto! A hoop skirt made with real hoops! (and duct tape, of course!)

Hoop skirt -- made with real hoops!


Travel Tips for Venturing OUT of Black Rock City

So! You’ve decided to take a trip away from Black Rock City!  Here are some tips to keep in mind when traveling away from Home:

Clothing: Make sure to bring enough clothes so that everyone in your group can have some. Among other things, will save you all time later since you won’t have to keep switching.

Stormy Bedroom Eyes

Travel:  A note of caution here! Some vehicles that appear to have extra room for more people may not be giving rides!  We’re not sure exactly why this is, but we’ve had several reports of this.  Always ask for explicit permission before getting into someone else’s vehicle — a friendly “Hi!” and a wave as you climb in may not be enough!  Use your judgement.  Also note that some vehicles may travel faster than 5 M.P.H.

Make sure you are at Burning Man...

Money: Do you remember when you were a child, collecting bits of money here and there, slowly saving up for that one thing you really wanted? Well, money here works the same way, except that you may have to break open your piggy bank a little bit more often.  If it helps, think of every shop, store, restaurant, gas station, bar, and mall that you see as if they were “Arctica”, and what they’re all selling is basically just ice: cool, and maybe useful, but ultimately fleeting and ephemeral. ‘Nuff said.

be 100% happy or receive 100% money back.*

Fire: Make sure to establish a safe perimeter around any burn events that you create.  This goes double for large-scale burns; many people you meet may be new to this form of expression and will greatly benefit from your love and guidance as they participate in the burning of any large-scale structures.  Also, you might want to ask permission from the structure’s owner beforehand, if you can find them easily.

And finally... The Man burns... and we are done.

Bacon: BACON IS EXACTLY THE SAME EVERYWHERE, THANK $%!*&@# GOD.

Returning Home After Your Trip: After you’ve had an exciting jaunt out and about, it’s always good to come back Home, to be with your family and your loved ones.  Have a wonderful trip, and we’ll see you when you get Home again.

Mighty Trojan Warriors!

Yours in flame-
-Mark