July 12, 2019

New uses for old smartphones: Function/Clock generator in Maker projects

An old smartphone can sometimes be a cheap alternative to expensive laboratory equipment.

I just rediscovered a breadboard with an old project on it while cleaning up. It was meant to become the control unit of a decorative firefly jar with individual LEDs fading in and out at random. Never got around to finish it and worst of all, I lost the source code. Shit!

But speaking of fading LEDs in and out. LED brightness is controlled by electric current. The desired current can/must be adjusted by using a pre-resistor. By using a potentiometer instead, brightness becomes controllable. Two problems, though:

  • Resistors waste energy.
  • It doesn’t work that way with a microcontroller.

Microcontrollers (at least the cheap ones) only supply constant amperage from their output ports. The way to dim an LED, using a microcontroller, is to rapidly switch the port on and off. Standard Pulse-width modulation. Nothing special.

Professional Function Generator, good but expensive
Pulse-width modulation is something, you always deal with when your circuit contains a quartz oscillator (pretty much every time, you want to step something). The stupid thing about these components is that they aren’t particularly flexible and you rarely have one with the right frequency on hand. So, whenever you want or need to experiment with PWM (different frequency, wave form or amplitude), you need a function generator. These things can be bought ready to use from specialist shops, but then they’ll easily cost an arm and a leg.

Screenshot: Functiongenerator APP by Keuwlsoft
Is there a cheaper option for hobbyists? Sure! Pulse-width modulation is used practically everywhere in communications engineering when an audio signal has to be sent to a speaker. So in principle, all you need to dim an LED electronically is an old smartphone with a headphone jack, a cut off headset cord and an MP3 file with 100 Hz buzzing noise. The more flexible solution, though, would be the Function Generator App by KEUWLSOFT. Easily to be downloaded using Raccoon with the search term: pname:com.keuwl.functiongenerator).

Happy tinkering!