Tag Archives: arduino

Plutarch’s Debut is Nigh

workbench

Plutarch 1.0 is scheduled to make his party debut two days hence at J’s Halloween 2016 bash. The active duration of the party is roughly four hours. Here are my goals for Plutarch 1.0 during that time:

  • he must not fall off my shoulder
  • his head must remain attached to his body

Spontaneous decapitation has been a serious issue for this bird. His good-enough-for-prototyping attachment system might not be ready for primetime. We’ll see.

Whether his electronics work for the frightful fiesta’s duration is almost secondary.

While I celebrate the success of Plutarch 1.0’s ahead of schedule completion, I’m excited to get his successor out of the prototyping stage.

Here’s what Plutarch 2.0 looks like as of Halloween 2016. Keep in mind his deadline is 368 days in the future:

p2point0

He’s a discombobulated mess. But he’s much improved over his predecessor:

  • got 3D printed bevel gears working
  • added avoicebox with categorized, individually addressable sound calls
  • wrote a Maya-to-Arduino animation translator for the jaw movement
  • wrote a file processor that handles the WTV020SD-16P’s wonky-ass file format
  • amplified Plutarch’s speaker so he can be heard over party din
  • made a 3D printed chassis that’s modular and easy to assemble/disassemble
  • added multiple microphone inputs so that he can turn toward the loudest sound in the room
  • replaced soldered joints with connectors

Plutarch’s jaw opens and closes in sync with his sound calls. He’s got reliable, if shaky, 3-axis head movement. All of these systems mostly work, at least in isolation.

I just have to put everything together into a single, functional organism, at which point I can start working on the final challenge: his animation decision trees. Plutarch 2.0’s almost there and I’ve learned a tremendous amount about electronics and robotics over the last few months.

Unfortunately, I’ve just run into a couple of walls.

too many wires

Too many wires. Not enough space inside the body cavity for Plutarch’s y-axis servo to rotate freely. Voltage mismatch between the Pro Trinket and the voicebox and no room to cram a regulator in there.

Working in this cramped space is difficult (especially with a splinted pinky), and the microcontroller’s going to have to move to a more accessible spot. The 90° connections between Plutarch’s control wires and the microcontroller are eating up way too much servo rotation room.

Complexity could be conserved by tying a couple of grounds together. Connections could be used with higher-gauge wire. Options exist, but we’re gonna need a hogshead of brain juice over the next few weeks to figure all this out. And cash. Cold, hard cash.

It pains me to buy a $13 part to fix a problem I might have forseen but when one considers that $13 is an average morning at Starbucks for some folks, the bad feels wither away. Also I take comfort in the fact that I really have no idea what I’m doing so expectations really shouldn’t be that high in the first place.

A year remains before Plutarch 2.0’s unveiling. Still much to learn.

Internet of Stranger Things

TLDR; I made a Stranger Things Christmas Lights wall that you can control by adding #InternetOfStrangerThings to a tweet. It’s outside my house right now, blinking. Go ahead, tweet to it.

justice

Halloween! That time of year when Makers, who, if we’re being honest, are a little odd to begin with, let their freak flags fly with electronic projects of every kind. If you’ve been keeping up with the Zhengs you’ll already know about Plutarch the pirate parrot and the Lovely and Talented Mrs. Zheng3’s Arduino-enabled Pirate Pendant, but we’ve got one more project in the hopper this season: a Christmas light wall inspired by runaway Netflix hit Stranger Things. Plus, you– yes, YOU can tweet to this wall and your tweet will appear as a eerie sequence of glowing Christmas lights outside my house.

Try it yourself! Be nice, you bastids.

Let There Be Lights

Head out into the wilds of Amazon Prime and you’ll find plenty of LED Christmas lights that might– and we must stress might— fit the requirements of this project. Point against: our crack research team was dismayed to find that most modern Christmas lights seem to be spaced between 4″ and 6″ apart, which simply will not do for an application where the letters are more widely distributed.

Also, it’s highly unlikely that your garden variety Sunday church picnic Christmas lights are individually addressable. So in theeeeeeory we could buy a roll of Christmas lights, hack them apart with a Dremel and wire cutters and hope they’re what we need, or we could just make our own. DIY is ultimately more satisfying, so to the 3D printer it is!

Filabot was kind enough to send me a free roll of PETG+ for review. This filament prints somewhere between clear and frosty white, depending on the thickness of the model’s outer walls. It’s easy enough to whip up a few dozen hollow Christmas lights bulbs in Maya. (Got access to a 3D printer? You can download these models fo’ free at the The Forge.)

bulb

We don’t need the durability or transparency of PETG for the Christmas light bases, so they’re printed in MeltInk PLA/PHA and spray-painted black. These bases screw into the bulbs and have enough empty space in the bottom to accommodate a cut-down female header for plugging and unplugging.

Organization is key to completing a project with so many little parts! There’s not a lot of space on them for labeling with proper digits, so I hashmarked each base with silver Sharpie. This will help keep the colors in the proper sequence when I string up the lights.

sockets

Recovering from Failure

Strap in, muggles. It’s going to get technical for about a few paragraphs here.

Around Christmastime last year I was working on a project where I was trying to read data from 60-odd sensors. This project ultimately cratered, and we shall refer to it in hushed tones as the Multiplexer Incident of Winter 2015. It’s mostly behind us now. Mostly.

On the plus side, I learned an awful lot about multiplexers and cabling and bought a slew of electronics and more hookup wire than I’ll ever use. We can apply those newly-gotten smarts and parts to the Stranger Things wall.

First off, for those uninitiated– WTF is a multiplexer? In this context, a multiplexer (or mux, if ye be in the know) is a doodad that reads many signals into a single channel, or distributes one signal to many destinations. This wonderfully-written post at bildr will tell you how to read from this Sparkfun mux breakout, and writing to the mux requires only a couple of small modifications to the code. We’ll be writing to this mux to light up LED’s in a specific sequence.

Of course you need a bunch of colored LED’s, also.

You don’t want to run an LED without a current limiting resistor– down that path lies a wastebasket of fried electronics. Each mux can handle up to 9 volts, but that’ll cook the LED’s right quick. Happily these colored LEDs can be handily divided up into two groups; those with an operating range of 2.0-2.2V, and those that run at 3.2-3.4V. I put one 186-ohm on the SIG pin feeding the 2.2V LED’s and a 119-ohm on the other mux running the 3.2’s.

I told you it was going to get technical for a few paragraphs.

We want these LED’s to be in a predictable Christmas-light-like order: red, green, blue, orange, pink, purple, yellow, repeat, so there’s some software mapping of mux-pin-to-LED happening in the Arduino code. Higher voltage LEDs are on the mux labelled B.

light map

Building A Wall, Except Mexico Didn’t Pay for It, I Did

The budget for this project works out to less than $100, including plywood but assuming you’ve already got a 3D printer in the basement and your time has no value.

Programming microcontrollers, navigating the Twitter API, and tying it all together with heat shrink and hope is easy. Building stable outdoor displays out of 2×4’s and plywood? That’s hard, man. Definitely out of my element here, especially since I don’t have an easy way to make miter cuts in 2×4’s.

Confession: during construction, a piece of plywood fell down and hit me in the neck.

With enough screws and construction adhesive the whole thing should hold together for a couple of weeks and hopefully not fall over onto any pint-sized stormtroopers. Here’s the finished product– hat tip to our local Sherwin Williams for the Coriander Powder color match of a laser-printed Stranger Things screenshot.

daylight

Plywood ships in a 2:1 aspect ratio, but somebody really should manufacture 16:9 sheets for those of us who occasionally cross discliplines.

The “wires” strung between the Christmas lights are black nylon rope; the actual wiring is done with hookup wire stapled to the back of the wall. I also added “@” and “#” and @Zheng3_jim to the original A-Z. (You should probably follow me on Twitter if you’re not doing so already, cause I tweet about cool Maker shizz ALL THE TIME.)

This dog’s breakfast of electronics parts are jammed into a (hopefully) waterproof Ziploc storage container attached to the back of the wall. It’s a mess back there with the breadboards and jumper wires, but should be good enough for a temporary installation. Note warning label on it to discourage tampering and/or theft.

picovolts

Sun Tzu says: appear weak when you are strong, and strong when you are weak.

Reading From Twitter

Oy. A detailed description of how to do this is beyond the scope of this post. Suffice it to say that I’m using Tweepy, OAuth, and a poorly-written Python script that you can download here. Be sure to swap out my placeholder authorization tokens with your own.

In pseudocode, here’s how this whole thing works:

loop:

read the latest 100 #InternetOfStrangerThings tweets from Twitter
pick a random tweet from the list
filter the results for harsh language
if no appropriate tweet is found, use something benign (HAPPY HALLOWEEN, JUSTICEFORBARB, etc.)
smoosh the tweet into ASCII code

loop:

send the ASCII over serial to the Arduino as bytes
map the incoming byte to a mux pin
light the appropriate LED
wait a little bit between letters

wait a little while between tweets

Presumably one of the chans or reddit will eventually catch wind of this project, so before we send any text to the Arduino it gets filtered against a text file of slurs and epithets I keep around for precisely this purpose. There are kids around, for fuck’s sake.

An old laptop sits inside, shoving sanitized data into the Arduino through a 30-foot USB cable. That’s right, the tweets are coming from INSIDE THE HOUSE.

Download the microcontroller code here for a sterling example of how not to program an Arduino.

Tweet anything you like with the hashtag #InternetOfStrangerThings and it’ll wind up on the wall if your text gets past the filters. I’ll be tweaking the code between now and Halloween to make it more responsive to input from Twitter, and if I can figure out an easy way to set up realtime video stream I’ll do that too.

Happy Halloween if I don’t talk to you sooner. Lao Zheng out.

Vacation Photos and RGB Sensors

So I’m back from a week travelling across the western half of Canada with the lovely and talented Mrs. Zheng3 and her parents. We now return you to your regular schedule of intermittent blog posts.

The trip began in Vancouver where I enjoyed the singular pleasure of spending a couple of hours meeting with the Pinshape team at their mothership. We discussed some of the more pressing questions facing 3D printing designers today, including but not limited to where one might obtain the best dim sum in BC’s fairest city.

Great bunch of folks, these Pinshapers. Sharp as tacks and friendly to boot. Take a look at their site and you’ll find a nicely-curated selection of models.

Robber Rex (a favorite at Pinshape) managed to visit the Vancouver Public Library, which has been cunningly constructed to resemble the Roman Colosseum.

vpl

hashtagRAWR.

The Saskatoon train station is as bleak an outpost as you’ll find, but still a welcome diversion for a constipated Parasaurolophus who never quite got the hang of pooping in a cramped train toilet.

saskatoon

The long train ride from Vancouver to Winnipeg, made longer by frequent sidesteppings to allow freight trains to pass, allows for much contemplation and idea generation and idle sketching upon napkins, and by the time I returned home I was more than ready to jump into the next project: RGB color sensing with Arduino.

There are, presumably, roll-your-own RGB sensors cobbled from disposable contact lenses, photoresistors, and Oreo cream, but at some point one must accept that expedience takes priority over molecular-level knowledge of a process and you just can’t be mining your own beryllium all the time. So to Adafruit we go, and earlier this week a TCS34725 RGB color sensor arrived on the doorstep of Zheng Labs.

milton inspecting

The Adafruit tutorial is remarkably easy to follow and we were up and running in less time than it took to print George Timmermans’ handy Arduino and half-sized breadboard caddy, including the time required to solder the sensor to some headers with long-unused and filthy soldering iron tips.

I’d link to the caddy directly except that WordPress is throwing some weird Unicode error and it’s too early in the morning to troubleshoot HTML errors. It’s on Thingiverse.

This little board contains a white LED that burns with the intensity of a thousand suns, so you may want to wire it to ground and turn it off while you’re experimentin’ or you’ll be seeing afterimages of your workspace for hours.

caddy

The book in the background is fellow Wisconsinite Jordan Ellenberg’s How Not To Be Wrong, which, 50 pages in, is so far a fun read. Any book that starts off with a humorous telling of statistical analysis of bullet holes in WWII airplane fuselages is going to be good.

Our engineering team ran into a little bit of trouble trying to get Unity3D to talk to the Arduino and settled for a temporary solution using Python code direcly cannibalized from 2012’s Etchasketchulator project:

import serial

ser = serial.Serial('/dev/tty.usbserial-A700fjTr', 9600)

def wait_for_arduino():

     while (true):      
          valueIn=ser.read(50) #read the first 50 characters that the arduino is sending
          print (valueIn)

wait_for_arduino()

That /dev/tty.usbserial-A700fjTr serial address is the currently free USB port on my MBP: if you’re using a PC you’ll likely replace that string with something that looks more like COM4. Check your Arduino IDE to see which port to use.

serial screenshot

Looks like I need to make the serial communication a little more elegant; it’s timing out, throwing errors, is badly formatted, and generally a mess. But let us not let the perfect be the enemy of the good. Iterate now, fix later.

ball pit

I used a couple of ball pit balls as test objects. In the interest of presenting properly-formatted data let’s go direct to the Arduino serial monitor for the output:

Offscreen I’m waving a red ball over the sensor and, wonder of wonders, the red values change over time.

arduino serial

Next step: communicating with a passel of these RGB sensors. This should be a challenge, since each one has an identical address and as far as I know they can’t be changed in hardware. Getting ready to hop on the I2C bus.

I’ll clean up the serial communication by next time, promise. And calibration. Gotta do some pre-read calibration of the sensors for ambient light levels, too.

Note to self: buy new soldering iron tips before we go down this road. #staytuned.

Hack-O-Lantern

Halloween fast approaches, and I still haven’t managed to make that electroluminsencent Riddler costume I’ve been dreaming about for the last two years. But this year I did manage to come up with a nifty Hack-O-Lantern that uses an Arduino and a pair of diffusers that I printed on my MakerBot Replicator. Here’s what the animation looks like, including my new favorite function, derp().

My apologies for the soul-deadening ambient light in the video. The Hack-O-Lantern looks a lot cooler in person, although if I had more time I’d try to boost the voltage to the LED’s and brighten them up a bit. Right now they’re running off straight off the Arduino, and I didn’t want to burn out any pins by driving too much juice. Maybe next year.

You don’t need to use an Arduino to use these diffusers: if you’d rather just stick a couple of LED’s in there with a watch battery taped to the leads, that will work just fine. The LED’s in the top photo are running in series off 4X 1.2V NIMH 2500 mAh rechargable C cells, and they look great.

The diffuser has a slight lip on the back that you can use to score your pumpkin’s flesh before cutting.

Nightmare fuel, anyone? Here’s all 14 LEDs soldered to hookup wire, fed through the pumpkin’s eye holes.

Once I connected the LEDs to pins 0-13 on an old Arduino Duemilanove I had kicking around (SCORE for finding a set of headers I’d forgotten I ordered six months ago), I put the whole contraption in a plastic bag so the pumpkin guts couldn’t short the hardware.

Working inside that cavity gives you a lot more respect for brain surgeons.

If you’ve carved a pumpkin recently, you’ve probably got some seeds kicking around. Here’s what I’ve been doing with them lately:

Zheng3 Szechuan Pumpkin Seeds

approximately 1.5 cups of pumpkin seeds, washed.
1 tablespoon doubianjiang
1 teaspoon light soy sauce
1 teaspoon hot chili oil
2 tablespoons peanut oil
1 tablespoon Szechuan peppercorns

Mix everything except the peppercorns in a bowl and toss to coat. Set aside for an hour to marinate.

Toast the peppercorns in a wok over medium heat until fragrant. Crush with a mortar and pestle.

Spread the pumpkin seeds and marinade evenly on a flat baking tray. Bake at 350° for about 20 minutes. Sprinkle with the crushed peppercorns and serve.

If you can’t find doubianjiang and you’re not willing to wait for a shipment from Amazon you can probably substitute some garlic powder mixed with Sriacha rooster sauce.

Approximating the flavor and mouthfeel of Szechuan peppercorns is more difficult. Try this:

Dip a jalapeño pepper in powdered laundry detergent and suck on it for 30 seconds. Then put your lips across the terminals of a 9V battery.

It tastes better than it sounds, believe me.

You can download the STL’s and Arduino code here.