I am looking for ideas of how to capture and replicate a waveform with an Arduino Uno. The waveform will be measured electrically (e.g. on an analog pin) and output on a different audio pin,(kind of like an arbitrary waveform)
What is the easiest way to do this while keeping the two signals separated from each other?
Thanks for your help
First consideration, the UNO doesn’t have any ‘audio’ pins…
To go ahead with this idea, you need to solve this issue, the for very short waveform samples, you could ‘record’ a stream of samples from an analog input, the ‘play’ that sample back via suitable D/A output arrangement of your choosing.
You may find more options and storage capabilities by using a different processor.
Considering that the Uno has no audio output and doesn't even have a true analog output, I think the easiest way is to ditch the Uno and get another controller.
what frequency and voltage is your signal?
The UNO R3 has no DAC but you can add one.
The MCP4912 is a 2 channel DAC using 10 bits which matches the UNO's ADC.
You can use this library to control it.
For the AVR only I wrote an async version of analogRead() long ago. This library allows you to handle e.g. storage, while the ADC makes a measurement in the background.
dipends what is your scope!
Low frequency signals can be reproduced by arduino uno using its pwm pins
Quality of sound will not be great. Speech may be comprehensible...
Otherwise: get a faster MCU.
Also: the uno can hold only seconds of audio data.
May be sufficient if your signal is continuous (something like a saw tooth, block or sine wave).
Addition if an SD card reader won't help much as it takes a lot of RAM to run the card reader.
You might use a board like a mp3 recorder/player and control that from the UNO.
Which one, the "Q", R4 or R3?
Do you really want to sense audio, change to digital, then play audio? Your phone can do that by pressing RECORD on an audio app.
You say "waveform" but probably mean "amplitude" representation of a multi-frequency, non-negative, time-versus-voltage," A-to-D trace.
Here is a simple, "a-to-d trace" using the randomness of an un-tied Arduino pin outputting the "trace" to the serial monitor...
void setup() {
Serial.begin(115200); // start Serial Monitor communications
delay(2000); // allow communications handshaking to complete
}
void loop() {
int reading = analogRead(A0); // get "digital" value 0 to 1023 bits
int spacing = reading / 20; // map 0 to 1023 to 0 to 50
for (int i = 0; i < spacing; i++) // move the cursor right...
Serial.write(32); // ... using spacebar
Serial.write(42); // ... and add asterisk at end of line
Serial.println();
}
And, here is a simulation of four analog inputs with "waveform" trace output in the Serial Monitor.
A sound waveform has complex elements, isolating one frequency, creating an "envelope" with the elements of "attack, decay, sustain, release." The element "attack" is how quickly the sound goes from zero to its peak level (a bell can have a fast attack after the percussion). "Decay" is the level after "attack" is finished where the sound persists (a bell has a small decay as it rings). "Sustain" is how long the "decay" lingers, the bell example has a long "sustain" level. "Release" is how long the waveform goes from the initial sustain level to silent, where the bell example has a long release stage. Hitting a stick with another stick will have a short attack, a short decay, a short sustain and a fast release. Here is an example simulation of adjusting the ADSRVF (attack, decay, sustain, release, volume, frequency) of a waveform envelope.


