Control Up to 4 Servo Using a Smartphone or Any Device With an Audio Output

Here I present a simple electronic montage to control up to four servos with any device able to read an audio file!

Step 1: The Principle

Servos are drived using a PWM signal between 1ms (no rotation) to 2ms (full rotation), spaced by 20ms start to start. More on WIKIPEDIA ! :)

Such signal can be carried through an amplified audio signal, like the one that get out of your mobile phone. Here I present a simple electronic montage, adapted from here. The basis is two transistors which amplify the audio signal to an high enough voltage. The first transistor is a NPN, which is activated when a positive voltage is applied. By adding a second amplifier, with a PNP transistor activated by a negative voltage, we can control two servos by audio channel. Since most devices (smartphones, PC, ...) have 2 channels, you can control up to 4 servos !

Step 2: Hardware

You will need :

  • 12 10k resistors (10 are sufficients, but 12 are easier for this montage)
  • Some wires
  • 6 NPN transistors (BC337 or equivalent)
  • 2 PNP transistors (BC327 or equivalent)
  • A breadboard and its power supply (5v)
  • 4 servos

Connect everything like on the picture. With the BC3X7, the flat side face the power line of the breadboard, and for each transistor : (left to right) Collector, Base, Emitter. This may vary depending on your references. A capacitor may be useful on the powerline to avoid any interference between servos. Or connect the servos drived by the PNP transistor to the second powerline.

Step 3: The Software

I coded a little python script to produce a series of audio files that, once played, position the servo accordingly. It generate files with pulses from 0.8 to 2.6 ms. While servo are supposed to work with signal from 1 to 2 ms, the margin my be usefull to use the servo to its true full range.

In addition, I made an App Inventor project which play the audio file depending the position of the sliders.

First Time Author Contest 2018

Participated in the
First Time Author Contest 2018

Epilog Challenge 9

Participated in the
Epilog Challenge 9

Share

    Recommendations

    • Beauty Tips Contest

      Beauty Tips Contest
    • Planter Challenge

      Planter Challenge
    • Sensors Contest

      Sensors Contest

    3 Discussions

    0
    None
    -Skar-

    1 year ago

    This is a really cool idea. For a further improvement, it would be good to add a flyback diode for every servo in parallel (in block direction). Else the transistors may get damaged overtime, like with every inductive load.

    1 reply
    0
    None
    tomatoskins

    1 year ago

    Wonderful information!