• Category Archives Arduino & Electronics
  • Arduino projects

  • Projects » Arduino & Electronics
  • Arduino Flickering Code

    A number of people have asked me for the code for the Flickering LED for my Steampunk Tesla Cane.

    It’s a modified version of the standard “Fade” Arduino example code. The original code I borrowed appears to have disappeared, but this instructable (not mine) has some “flickering” sample code: that is very similar:

    Flickering Arduino Instructable

    Roughly, you make an array of values (the flicker[] below) and cycle through them. Some versions are far more complex, and generate a pseudo-random number for each step instead of a static set of values.

    int ledPin = 10;
    byte flicker[] = {180, 30, 89, 23, 255, 200, 90, 150, 60, 230, 180, 45, 90};

    void setup()
    {
    pinMode(ledPin, OUTPUT);
    }

    void loop()
    {
    for(int i=0; i,7; i++)
    {
    analogWrite(ledPin, flicker[i]);
    delay(2000);
    }
    }

     


  • Sources for parts

    I’m often asked about sources for parts, and it always comes up when my friends and I do our Teslapunk panels.

    Our two favorite sites are Sparkfun and Adafruit. Each has it’s own strength and weaknesses: Sparkfun is closer for those of us in the West (they’re in Denver) and while they have a large selection of parts for the electronics Maker, they focus a bit more on robotics. Adafruit (based in New York) is an amazing company that was worked hard on bringing a curated selection of products to the Maker community, and produces their own versions of the Arduino microcontrollers: the Gemma, designed to be worn in clothing and the Trinket/Trinket Pro, which are much smaller than the original Arduino. I discussed both the Gemma and Trinket in my post “But the Arduino is too big for my project.” Adafruit also sells the Neopixel product line of programmable RGB (Red/Green/Blue) LEDs available in variously sized rings, strips, and individually. These are the multi-colored LEDs that Thadius Phule (Peter Valentine) uses in a number of his gadgets. I also buy my Lithium batteries from Adafruit.

    For generic electronic parts I check both DigiKey and Mouser, but I also check ebay. Buying through ebay can save you a lot of money if you’re willing to wait while they’re shipped from China, but if you don’t get exactly what you expect, you can be SOL. I’ve generally had good luck, but I’ve stuck with components (LEDs, battery cases, etc) and not full Arduinos. Peter does use ebay for his Arduinos and has had good luck.

    More to come!


  • Changing with the times: Tesla Cane electronics rebuild

    It’s been a busy few months without posts, but there is lots of stuff going on, some of it even coming off the back burner!

    Wild Wild West Con 4 is rapidly approaching…and since my Tesla Cane Mk II (with a copy of the Mk I electronics but with the original chip) is in the Sky Harbor Airport Steampunk Exhibition as I mentioned last time, I needed to rebuild the electronics for the Mk I cane itself. I somehow lost (or maybe they were …stolen by an Airship Pirate Gang?!?!) the original code for the flickering, I needed to recreate it. I actually found an earlier version I was fairly happy with in a separate backup, and it made sense to rebuild all the electronics using a Trinket instead of the barebones chip: easier programming (via the built-in mini-USB), battery/voltage management, easy reset, cleaner pinouts, etc.

    The Mk I electronics were very simple (see here): I used a bare Atmel ATTiny chip, a resistor, and LED. In the last few years Adafruit and other companies have come along and make really awesome low-cost ATTiny-based boards (I covered them in this post about what to do when an Arduino is too big for your project), and I’d pickup up a couple of the Trinkets to play with. Since a bare ATTiny chip is $2-4 individually and a Trinket is $8…that seems a decent deal.

    So, out with the old:

    Tesla Cane Mk I Electronics
    Tesla Cane Mk I Electronics

    And in with the new:

    Tesla Cane Mk II Electronics
    Tesla Cane Mk II Electronics

    The Trinket is slightly bigger, but being able to reprogram via USB is a great advantage!

  • Playing with a Neopixel Stick: Lithium Polymer (LiPo) battery sample use case

    In my last post, Batteries, batteries, batteries! (Or, how do I power this thing!?) I mentioned the power and flexibility of Lithium Polymer (LiPo) batteries for your projects, but said I mentioned that I hadn’t started to work with them.

    For an upcoming project, using an Arduino Gemma (which I talked about in my post about “But the Arduino is too big for my project!“) I decided to use a LiPo battery, since the Gemma conveniently has a JST battery connector on it.

    As a test,  I connected a NeoPixel Stick — another awesome piece of kit from Adafruit, to the Gemma. The Neopixel Stick, like all Adafruit’s Neopixels, is a string (in this case, a stick) of RGB LEDs with a built-in color controller. The Stick is 8 of these LEDs on a rigid circuitboard.  Each LED in the stick is really three sub-LEDs, one in Red, Green, and Blue (hence RGB). With these three sub-LEDs, you can make almost any color you can imagine. Because of the built-in color controller, you only need a single data pin (besides the two normal power connections) to control an entire group of LEDs!

    Adafruit NeoPixel Stick
    Adafruit NeoPixel Stick
    Rear (you only need 3 connectors)
    Rear (you only need 3 connectors)

    Note that if you are interested in NeoPixels (I learned about them from my friend Jeff McDaniel, who did the Teslapunk panel at Phoenix Comiccon) you should read Adafruit’s entire Uberguide, here. I’d call them a medium difficulty item, as there are some power requirements to be aware of…in short, the individual pins on an Arduino can’t handle the amperage for many of these LEDs, so you need to directly wire them to power.

    To test the LEDs, I connected the appropriate pads on the Stick to positive, negative, and D1 (digital pin 1) on the Gemma. I ran a “Larson Scanner” test — this is named after Glen Larson, who was the producer of the old Knight Rider and Battlestar Galactica TV shows, which both featured a red moving LED light (on KITT the car’s front bumper and the “eye” of the Cyclons). This test basically chased from one LED to another and altered the colors each time.

    Here’s a demo video of the setup:

    The Neopixel Stick is held in the grip, the little blue breadboard in the middle is just linking the soldered wiring to the alligator clips connected to the tiny Gemma board. Notice the silver LiPo battery pack powering the Gemma!

     

    I’ll mention the Neopixels are really bright, wow!

    The LiPo battery pack is 850ma, and cost around $8. So, take a guess at how long it ran that Neopixel test?

    Over 30 hours, wow!

    I think I’ll be using LiPo more in my projects!


  • The TARDIS chocker is done!

    After a few fits and starts (finding a case I was happy with was really hard!) I’ve finally finished the TARDIS lantern necklace for my friend!

    It consists of a small Tim Holtz Lantern that had an incandescent bulb powered by 2 AA batteries, which I retrofitted, removing the cheapo flashlight bulb and replacing itwith a white LED. The wires run through black necklace chain to a battery pack that my friend will wear tucked in her corset.

    The battery pack is a cool little case from New Age Electronics (via Mouser) that combines space for 2 AAA batteries (more than enough juice for this) and space for a small circuit board on the opposite side:

    AAA Project Box Blowout
    AAA Project Box Blowout

    Note that if you’re going to use the same box (which I really like) the battery “plates” are seperate, just make sure you order those on Mouser, too. The circuit board is a stripboard I got from ebay, cut and drilled to size. The wires are heatshrinked and come in through a hole in the side:

    Sideview of completed box
    Sideview of completed box, wires visible. The side opposite the batteries holds the circuit board.
    The circuitboard
    The circuitboard showing the ATTiny and resistor

    The circuit is basically the same thing as the Tesla Cane ATTiny, except running a “fade” program I tinkered with to get a more Doctor Who-like effect. Here is it in action (I love this thing in the dark!):

    [youtube]http://youtu.be/4ccM563iOZQ[/youtube]

    Completed Choker
    Completed Choker

  • TARDIS lantern necklace first look!

    This is a necklace I’m making for a friend. The lantern is a tiny little thing by Tim Holtz that came with an incandescent bulb. I replaced the bulb with a white LED and control the pulsing using an Arduino. I’ll eventually replace the Arduino with an ATTiny and run the whole thing from a 3v button battery.

    [youtube]bO_qmfW1L4g[/youtube]


  • Project One: The Steampunk Tesla Cane lives!

    It’s alive!

    At long last, Version 1 of my Steampunk Tesla cane is done, just in time for the Wild Wild West Steampunk Convention!

    Steampunk Tesla Cane!
    Steampunk Tesla Cane!

    The original idea of using a Plasma Ball never really went anywhere, and when I saw another cane made by Der Geis while googling around, I decided to change directions a bit…

    For my cane, the upper cane body is made of Delrin, a plastic that is easily machined, made by a friend of mine who is an expect machinist and uses a lathe and Delrin for making many parts. The stuff is very easy to work with, but doesn’t accept paint well, so its still black, but it does look a bit rubbery, so that fits with the electrical theme. A future redo may use wood or some other material, but Delrin was an easy and fast prototype material. The entire section is held together by hex key screws so I could disassemble and change things around. Oddly enough, the hex key (Allen key) isn’t widely outside of “period” for Steampunk, having been developed around 1910! Future versions won’t need this flexibility, so I may redo the head in wood, or maybe not… The tubes are held in place by grease fittings called “zerks” that are used for greasing some engines, and I borrowed the idea from Der Geis’s cane. My friend also custom made the brass insert from round stock, as well as the aluminum end cap. The interior of the handle is hollow, houses the electronics and batteries, and is wrapped in leather cord for a grip and a sword-like appearance.

    Cane top
    Cane top
    Chamber closeup
    Chamber closeup

    The shaft of the cane is a wood dowel from another project, wrapped with twisted brass wire, and secured to the chamber of the cane with two more grease zerks, one for each wire. The twisting was done using a pair of safety wire twisting pliers. These are special pliers that are designed to twist wire together for safety links or jewelry. I love the look! Just google around for the “safety wire twisting pliers” and you’ll find them.

    Now to the insides! The light tube is the body of a “lightsaber” keychain, just like the one cane I’m pseduo-copying, but I didn’t just use the whole thing like he did. I removed everything but the plastic light tube, supplying my own blue LED. I built a custom circuit using an ATTiny85 (I describe that here) and googled around for interesting affects I could make. That boiled down to two: I could pulse the LED on/off or I could use a “flickering candle” style. I posted a poll (here) and the overwhelming result was the flickering…I agree, it looks like its working, but just barely…very Steampunk!

    Here is the entire circuit: the ATTiny85 in a socket for easy programming, the battery pack (3 AAA batteries in a round holder stolen from a $2 flashlight), a resistor, and the LED, heatshrinked into the end of the lighttube. The LED uses about 20mw of power and I get 1000mw from the batteries at around 4.5v…I left it running for 24 hours as a burn in and the batteries are still pretty full! I did not put in an on/off switch, as I didn’t have one that fit well, that’s for a future version.

    The guts photo
    The guts photo

    I don’t have a great video of the cane running in the completed form, but the effect is clear in this prototype video I made for my friend who worked the Delrin for me:


  • Which effect?

    Which effect do people like better?

    [youtube]http://youtu.be/CfGZiuZNEr0[/youtube]

    Which effect do you like better?

  • Miniaturizing projects: the ATTiny85!

    A couple of the projects I’m working on will require very small electronics that still need some sort of microcontroller to do something smart, like pulse an LED, respond to a button press, etc…For larger things, I’m using the Arduino series of microcontroller boards, powered by the Atmel AVR MCU (MicroController Unit), but often the final project is to be embedded in something, like a cane, visor, or prop gun, and a full sized Arduino board is too large, even the smaller ones, like the nano, and too expensive ($30+ ) for a complete board…and they are probably overkill for what you need, having far more pins (inputs/outputs) and unnecessary parts (like headers, onboard LEDs, etc.)

    I happened across a Make Magazine article called “How-To: Shrinkify your Arduino Projects” that describes using Atmel’s ATtiny AVR chips, which are a much smaller (8 or 16 pin) and much cheaper (I got mine for less than $1 each on ebay) version of the brain of the Arduino, the ATMega328. You have less pins (2 digital, 3 analog on the 8-pin ATTiny8x series) but the darned thing is tiny, the size of my pinkie fingernail! Note that you could do this with the larger and more expensive ATmega chips, but if all you need is a simple microprocessor, the ATtiny is pretty awesome!

    The Make Article references a post from “High-Low Tech”, an MIT Research Group. The article has since been updated to reflect the support in the newest Arduino IDE (1.03 as of this post) and describes how to wire up the ATtiny to the Arduino and program it via the Arduino IDE.

    To program the ATtinys, you need an Arduino to serve as the programmer and you either wire up via breadboard the ATTiny or use an Arduino Shield for it. I got a shield from a Turkish Company, Flytron, for $20, that does both the 8 and 16 pin variants. After the Make article, lots of companies are making shields and programmers for the ATtiny platform (Sparkfun and Adafruit being the two most common and popular, but they are also all over ebay.) I do wish the shield I got had a ZIF (Zero Insertion Force) socket, as the pins bend easily taking the chip in and out, but other than that, its a nice little shield!

    So, without further ado, here is my first programmed Atmel ATtiny85, running the Arduino LED Fade sketch! Its currently powered from a full Arduino board just for convenience, but sans battery the entire setup is smaller than the 2″x1″ breadboard its running on!

    [youtube]HvaMM4bh2hU[/youtube]