When SCALE approved my talk proposal,
with Linux and Devices, I had a challenge: I needed some good,
visual Arduino demos that would work in front of an audience.
In particular, I wanted something that moved. A little toy truck?
A moving penguin? A rotating sunflower? I fiddled with this and that,
not fully satisfied with anything. And then suddenly I realized what I needed.
Something cool. Something BIG.
Something I'd been wanting an excuse to buy anyway.
An Air Swimmers Shark.
I'd seen these things on video, but never in person. They're available
all over, even on Amazon, so I put in an order there and got a shark
in a few days.
These things are ridiculous and cool. It's huge, about 5 feet long,
and filled with helium. It takes maybe half an hour to assemble.
It has a small motor to beat the tail, an infrared transmitter,
and a weighted receiver that moves back and forth on a track to tilt
the fish up or down as it swims.
Once it's assembled, you can get it filled with helium at a party
store (which costs $3 to $6 depending on where you go).
Once the shark is filled, you add clay as ballast until the shark is
neutrally buoyant, neither rising nor sinking. It's quite sensitive:
you'll find yourself needing to add or remove pea-sized chunks of clay
as the temperature in the room changes, but being a little over- or
under-ballasted doesn't hurt it much.
With its tail beating, the shark really does look like it's swimming
through the air.
My shark is named Bruce, after the mechanical shark used for the movie
"Jaws". My Bruce, I'm happy to say, has been much more tractable than
his famously intemperate namesake.
Okay, now how do we turn this ridiculous-but-cool thing into an Arduino
Hacking the transmitter
There were two possible approaches. First, mount an Arduino directly
on the shark, and let it be totally self-directed. Second, patch the
Arduino into the shark's transmitter and control it from Linux.
I chose the second option, for several reasons. First, I was fairly
sure it would be easier, and less invasive (the shark would still be
usable with manual control). I also liked the idea of keeping the
transmitter as a manual override, in case my control program didn't
work right. Finally, I liked the idea of keeping a Linux machine in the
loop -- the shark would actually be controlled by Linux, not just by
So the first thing I did was take the transmitter apart (4 Philips screws).
Inside are 4 pushbuttons, for right, left, up, and down, and the circuit
board is nice and simple. Whew -- this might be doable!
Four more screws and I had access to the back of the board, which was
equally simple. Now I could get my voltmeter on the contacts while I
It turned out the contacts (indicated with arrows on the photo) on the
downstream side of each switch were normally high (4.5 volts -- the transmitter
uses 3 AAA batteries). When I pushed the button, the contact went to ground.
Okay, so what I needed was some way for the Arduino to ground those
contacts at will.
First I needed to solder some wires to the contacts.
(How do you tell which side of the pushbutton is the one you need to solder?
Well, one side changes voltage when you press the button, and the other
side stays constant. The one that changes is the one you need to connect
to the Arduino, so the Arduino can change it too.)
I figured I needed 6 wires: ground, power, and one for each switch.
(It turned out I didn't need the power wire, but I figured it didn't
hurt to include it just in case.)
I wanted to have a nice small connector on the side of the transmitter,
but I couldn't find any 6-pin connectors that didn't look big and bulky,
so I gave up and decided I'd just let my ribbon cable dangle from the
transmitter. If I got a nice multi-colored one, maybe it would look festive.
I couldn't find any 6-conductor ribbon cable, so I got a
wider one and separated 6 wires from the rest. Then I soldered the
six wires to the appropriate places (marked by arrows in the photo).
On the other end, I tinned the six wires with solder so I could plug
the stranded wires into my breadboard.
Simulating button presses
I've done enough reading to know of three ways to simulate a button press.
You can put a relay between the two contacts of the switch; you can do
the same thing, but with an optocoupler (opto-isolator) instead of a relay;
or you can do some magic with a transistor. I was fuzzy on the
transistor magic bit, so a relay sounded easiest.
I played around with a relay and a spare switch and convinced myself I
knew how to wire them up. Then it was off to my local parts store to
buy four matched relays small enough to fit on my little mini breadboard.
There followed a several-day fiasco wherein I bought lots of relays
that turned out not to be suitable, and got increasingly frustrated at
how large and clunky all the available relays were.
There are smaller ones, but I couldn't get them to work.
And I learned that relays mostly come without documentation on which
pin does which, so there's a lot of experimenting with each new type.
Frustrated, I tried some optocouplers I'd bought on a whim last year.
No dice ... couldn't get them to work either.
Desperate, I turned to IRC, #arduino on Freenode. The folks there are
mostly electronics wizards, and I'm sure my questions must have seemed
very dumb, but they were patient with me, and pointed me toward
a very simple circuit,
that was just what I needed. (They also suggested
collector article, but I found that less clear.)
It took me some
experimenting with a transistor, an LED and a couple of resistors
(I blew out a couple of transistors before I realized I had the R2 resistor
in the wrong place) but eventually I got it working, and felt confident
enough to try it with the real shark transmitter. The key was to simplify
the circuit so it had no extra parts, then once it was working, add more
parts to build it up to what I needed.
At left, the circuit I ended up with. For each button, I have one
transistor and one resistor (I don't need the second resistor from the
LED4dummies circuit, since that was just to keep the LED from burning out).
At right is the circuit assembled on a mini-breadboard on top of the
Note that the ends of the ribbon cable are plugged in to a spare header I had
lying around; a header makes a passable connector, so I can plug it in
fairly easily right before a talk. The green and blue wires in the back
are going to Arduino digital output pins 3 through 6 (leaving 0 and 1
for serial I/O). The red wires go from the transistors back to the
ribbon cable wires that go to the shark's transmitter buttons.
The software side
Now I could make the shark think I'd pressed a button on its transmitter.
How do I control that from Linux?
On the Arduino side, I wrote a simple program that reads and parses
commands coming over the USB cable. So from the computer, I might send
a line like
L 300, and the Arduino would "press" the Left
button for 300 milliseconds. I had already written something like this
for a couple of other Arduino programs. That program is
On the Linux side, first I needed something that established a serial
connection and sent commands to the Arduino. I wrote a Python class
That let me send commands from the Python console to test the shark.
Then I needed something more visual, something I could show during a talk.
In particular, the shark doesn't swim unless someone's pressing left,
right, left, right buttons over and over. Of course I wanted the computer
to handle that part.
So I wrote a little Python-GTK application that keeps the shark swimming,
and lets me drag a mouse around to adjust its left/right up/down direction:
Purely by coincidence, the week before SCALE, Scott Adams introduced a
Dilbert, Jan 11 2012.
Nice timing for the debut of my own roboshark!
Sadly, I don't have any photos or video of the shark in action.
But if you're a LWN subscriber, there's an article on my talk
with a couple of great pictures:
Robots rampage (in a
friendly way) at SCALE 10X.
And you can see my slides and notes at
Tags: arduino, hardware, robots, radio control, maker
[ 14:02 Jan 27, 2012
More hardware |
permalink to this entry |
I gather indoor R/C airplane flying is fairly common in some areas of
the country. But here in the Bay Area, there's been a lot of demand
and not many opportunities to do it, so there was great excitement
at a recent opportunity to rent Sunnyvale's community center gym
Indoor flying has come a long way.
I remember a couple of years ago when most of the indoor planes
were either "3-D" planes like my
that can stay in a small area by hovering, or weirdo concoctions
There were a few pioneers who used microminiature actuators and
other fancy hardware to build tiny lightweight custom planes, but
that was an expensive and difficult proposition.
But lithium-polymer battery technology and advances in tiny
servos and brushless motors have created a revolution in super
lightweight micro flyers, led by the
Vapor (Dave's is pictured at right). At a flying weight of half
an ounce, the Vapor makes it easy for anybody to fly in a small gym
or even a large room.
For folks who want something a little faster and more aerobatic, the Mustang
is a bit heavier at 1.2 oz, but still flies well in a gym.
And of course, there are the hundreds of micro-helicopters
that are popping up everywhere over the last year or two.
Pretty cool stuff! Anyway, we had a great session on Friday flying
these planes, and amazingly avoided any serious carnage (unusual for
indoor flying where there are so many walls and basketball hoops to
smack into). I'm a little out of practice and found the flying a bit
intense, so I took a few breaks between flying sessions to shoot photos.
For the new year this is going to turn into an AMA-chartered club,
BAM (Bay Area Microflyers).
Watch the BayRC forums for more details.
Tags: planes, radio control, indoor flying
[ 15:13 Nov 22, 2009
More misc |
permalink to this entry |
I'm flying R/C electric planes again. I'd overdone it a few years
ago and burned out; it stopped being fun and I had to take a long
break from flying.
But lately I'd been hearing intriguing stories from Dave about the
group he flies with at Baylands. They weren't doing the endless
hovering-and-rolling-circles that's all the rage in electric R/C
circles. (Not to disparage 3-D flying; anyone who can coordinate a
rolling circle gets my respect as a pilot. I just lost interest
in spending much time at that sort of flying myself.
No, what they've been doing lately is combat flying ... dogfighting.
The kind of flying I always thought looked most fun, only
Dave and I could never get anyone else interested.
You mean, there's a whole group of people dogfighting
and I'm missing it?
When I came out to visit, a couple of my old dusty planes in tow,
Dave let me use one of his old Boomers
(a bit easier for a rusty pilot to fly than the full-on
for the combat. We only had 4-5 planes in the air, but I was hooked
right away. Dogfighting is way more fun with five planes than it is
with only two. It's still surprisingly difficult to hit each other,
even when that's what everyone's trying to do. But even when you
don't make contact, it's exciting and beautiful.
When you get a lot of planes in the air, twisting and turning and
looping and trying to stay in a little compact region because that
makes it more likely they'll hit, Dave put his finger on what it's
most like. You know those David Attenborough nature shows where
a huge school of sardines or anchovies has gathered, and dolphins
herd them into a tight compact ball of shining shimmering silvery
streaks, and then the seabirds come and dive from the air while
the dolphins are darting in and out from below? Attenborough calls
it a bait ball, and that's what Dave calls our combats.
We're gradually pulling in fresh mea--er--new recruits
to add to the fun.
A week ago last Saturday we all trooped up to Dublin to meet with
some east bay combat flyers. We had as many as ten planes all
fighting at once. Pete has a
online of the Dublin Melee ... video from a digital camera really
doesn't get the feeling across, but it's a start, and gives some
idea of the challenge of keeping track of which plane is yours.
Try imagining David Attenborough narrating about the bait ball while
you watch the video. Helps a little, doesn't it? Or if you're going
for the feel of combat, ditch the narration and play something like
the "Asteroid Field" theme from the first Star Wars.
Tags: planes, combat, dogfight, radio control, baitball
[ 22:20 Sep 30, 2008
More misc |
permalink to this entry |