Controlling a Motor with Snap!

Following up on the earlier post regarding inexpensive ways to control a motor with Snap!

we have taken a different approach. We connected a DC motor to the output of the headphone jack of a laptop, using a diode to rectify the signal.

We then used a tone generated by Snap! to control the motor. Here's a short video of a demonstration:

The 1N4001 diode cost 15 cents, so this approach offers an inexpensive way to control a DC motor with Snap! without requiring any extensions. (We did use an amplifier to amplify the signal, but we already had those on hand from another unit in which students design and fabricate a speaker.)

I like the Out Of The Box thinking here :slight_smile:

so its similar to Scratch Lego Mindstorm? Cool! I have always wanted to use Snap! to affect physical things like motors:p

I wish Scratch would have Arduino libraries or something. It would be nice. But you know, Scratch is more for kids and Arduino is more for teens of 8 and above. Or I think it is.

Either way, I think Scratch Team won't add it in.

I love using amplified audio output plus a diode to control the motor! Did you try using pulse width modulation to change the motor speed?

@earthrulerr and @slate_technologies: You might be interested in MicroBlocks (url:, a free, Scratch-like blocks language that runs in a Chrome or Edge browser (no install needed!) and works with fun, inexpensive microcontorllers like the micro:bit. Jens Mönig helped develop MicroBlocks and is still an advisor, so you'll find many similarities to Snap!. :slight_smile:

I’ll look at it!

We got just far enough on Friday to see that pulse width would be feasible for speed control. We’ll explore further when we return after the holiday.

Thanks for telling me about it! I will probably be buying a Micro:Bit and be using this program in the future! I had used Arduino and other similar products that my school had owned and attempted to use Snap! but could not get it to work properly. This seems much easier! Thank you.

Could you elaborate?

Well at the time (I say this because I haven’t checked since if it still exists) I used the Arduino library and the Arduino website to help me with using Snap! and it wouldn’t work correct.

We did some further exploration today. As you would expect, the amplitude of the waveform driving the motor is related to the speed of the motor:

Cool! Changing the amplitude of the audio signal is simpler than what I was thinking. There's no need to use pulse width modulation since the audio output already gives you a way to vary the peak-to-peak voltage.

Looks like you're driving the amplifier at 100 Hz.

Using higher frequencies -- say, 1000 to 5000 Hz -- might allow you to use a smaller capacitor to smooth out the rectified voltage. But perhaps it wouldn't make much difference...