This project is a synthesis of analog and digital, of programs and audio circuits. It uses zero dependencies, fully original code, and homemade analog circuitry.

Inspiration

Although the Arduino has analog inputs, it cannot truly be said that it has analog outputs. Its closest option is pulse-width-modulation (PWM) outputs, but its application to analog signals is limited, un-intuitive, and non-extensible. When used for audio, the result can be low in resolution and choppy.
Applications for a simple yet flexible Arduino signal generator are numerous. The design can be simplified, translated across platforms and, when optimized, included in the hardware of small IoT devices for sound or voice feedback ("The temperature is __"). The Arduino can be programmed as a speech synthesizer, or a musical synthesizer. Any waveform can be programmed into the Arduino, and with a few added controls, it can become a low-cost, accessible platform for K-12 students to use for learning analog electronics.
The goal of this project is to develop a foundational and extensible platform for generating analog signals with the Arduino, and to demonstrate a potential use with an amplifier-driven audio circuit.

What it does

The base code, when fed an array of signal values, loops through said array and outputs these values to an external n-bit (6 in this project) R-2R digital-to-analog converter (DAC) at set intervals. The result is a fluctuating voltage signal with n bits of resolution. The frequency, so long as it is not too high (I would estimate above 1kHz), can be set to any value, as well as the array of signal values!
The audio circuit extension included in this hack amplifies the voltage output, using two homemade, 10 V power supplies (batteries connected to voltage regulator circuits I soldered) and an inverting operational amplifier connected to a potentiometer (for adjustment of amplitude). This output is then transferred to the speaker, which plays the signal.

Potential Improvements

First, there is still noise in the output signal (originating from the non-simultaneous updating of digital pins) that can be smoothed over. Moreover, I did not have time to add further improvements onto the audio circuit; if I did, filters, transistor power amplifiers, and power supply capacitors could all be useful additions to improve the robustness and quality of the output. Currently, the signal fed to the dual-supply audio circuit comes from a single-supply circuit (the 5V power supply of the Arduino) and has only positive values; it should be biased by -2.5 V to (once amplified) make full use of the positive and negative ranges in the audio circuit. Finally, I would have optimized the code for speed (to increase the maximum frequency possible) and added controls for adjusting frequency and waveform in real time. However, with a solid baseline platform implementation, these steps are most definitely achievable!

Future Projects and Reflections

Through this project, I've learned much to carry forward into future implementations: How to combine my knowledge of Arduino programming and analog electronics in a single application; how to solder at home; how to design voltage regulators and batteries to supply a stable voltage for op-amps; how to scavenge my house and electronics for parts (the speaker I used was ripped from a toy!); and how to use a USB oscilloscope. I learned what was possible, and what limitations existed for the Arduino! And most of all, this was a lot of fun, and very rewarding to pull off.
There's a lot that's possible for a future project. Three stand out to me: First, create an Arduino music synth with different timbres and an octave of notes, as well as a transposition function to shift the pitches. Second, attempt to achieve speech synthesis, either in its true form of generating words from fundamental sounds or outputting prerecorded words. Finally, translate the program onto an FPGA -- potentially without using a softcore processor, so that it's fast and lightweight!

Built With

Share this project:

Updates