0

Turning tunes into toons: Build a drawing robot using two servo motors operated by any audio player #robotics

Sean sent in his great project that he posted over at Make. Thanks for sending this in Sean!

The servos in your R/C car, plane, boat, or ‘copter are controlled by a stream of electrical pulses sent from the onboard receiver. The length of these pulses tells the servo what angle to turn to. You can connect your R/C receiver to an audio input on your stereo or computer and listen to this control signal directly — it sounds like a harsh, rasping buzz pitched near the low “G” on a piano keyboard.

NewImage

This trick works the other way, too: Plug a servo into an audio output (like a headphone jack), then play the right sound, and you can control the servo’s position directly, without a receiver. A “mono” signal can control a single servo, and a stereo feed can control two — one on each channel.

NewImage

We first learned about this clever hack at Bay Area Maker Faire 2012, from exhibitor Kazuhisa Terasaki. Kazuhisa would go on to write Smartphone Servo for us in MAKE Vol 34. His Gluemotor app, which allows you to directly control the rotational positions of two standard hobby servos through your device’s headphone jack, is available as a free download for both iOS and Android. Here we’ve adapted the same basic idea to drive a super simple robot arm with two degrees of freedom.

CAUTION: Kazuhisa’s original schematic includes two 0.1μF ceramic capacitors — one between each servo and the headphone jack. He believes these capacitors should be included as a precaution to protect the controlling device from electrical damage. We have found that running the audio signal through these capacitors badly distorts the PWM waveform and limits both the variety of servos with which TRS Drawbot can be built and the accuracy of the drawings it can produce. We have built five prototypes and used them to create dozens of drawings from four separate devices without any problems. We believe that running TRS Drawbot, even without capacitors in the circuit, is very unlikely to damage your device, but we cannot guarantee that it won’t. Proceed at your own risk.

On a standard headphone plug, the left channel comes through the outer “tip” contact, the right channel through the middle “ring” contact, and the ground connection through the inner “sleeve” contact. The acronym for these so-called “tip-ring-sleeve” connectors is where TRS Drawbot gets its name. It has no microchips or circuit boards and uses free software to turn line graphics into sound files that make almost any audio device into an on-the-go robot controller.

NewImage

HOW IT WORKS

Because we have only two channels to work with, we can’t send “pen up” or “pen down” commands to TRS Drawbot, and are thus confined to single- or continuous-line artwork. In practice, this is not as much a limitation as it might seem.

NewImage

There are several ways to produce continuous line art, but perhaps the most interesting is to start with a normal raster image, create a “stippled” version (which represents the image as a large number of dots), then use a traveling salesman algorithm to find the shortest (or near-shortest) single path that connects them. This type of continuous line art is sometimes called “TSP art” (for Traveling Salesman Problem). Our pals over at Evil Mad Scientist Laboratories have produced a wonderful, elegant, easy-to-use program called StippleGen that makes producing TSP art from raster image files a breeze.

The Drawbot WAVE Synthesizer software reads in an ordered list of 2-dimensional Cartesian points from an SVG file (like those output by StippleGen) and scales it to fit the real dimensions of your paper. Then, using some simple trigonometry (plus basic user-defined data like the lengths of your Drawbot’s arm segments) it converts those points into a series of angles for the servos. It also adds an adjustable “easing” delay (to make sure new angles aren’t sent to the servos faster than they can react) and automatically interpolates points as needed, so that two distant endpoints will end up connected with a straight line (instead of the curved arc the servos would otherwise naturally produce). Finally, it encodes the servo angles as a series of PWM pulses and saves the result as a raw WAV sound file.

See the full tutorial here.

NewImage


Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, or even use Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for MakeCode, CircuitPython, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.

Join 12,000+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

CircuitPython 2019!

Have an amazing project to share? The Electronics Show and Tell with Google Hangouts On-Air is every Wednesday at 7:30pm ET! To join, head over to YouTube and check out the show’s live chat – we’ll post the link there.

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Follow Adafruit on Instagram for top secret new products, behinds the scenes and more https://www.instagram.com/adafruit/


Maker Business — SiFive is a startup to pay attention to. RISC-5 is here to stay.

Wearables — Swatch it up

Electronics — Code like everyone’s watching

Biohacking — Stroboscopic Visual Training

Python for Microcontrollers — CircuitPython takes flight! All aboard with datum, Bluefruit CPX, and more! #Python #Adafruit #CircuitPython #PythonHardware @circuitpython @micropython @ThePSF @Adafruit

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !



1 Comment

  1. If you want to produce PWM directly from an HTML5 Web App, see this page:
    http://techref.massmind.org/techref/io/servo/wav.htm

Sorry, the comment form is closed at this time.