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 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: microblocks.fun), 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!.
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.
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...