Play sounds

Viewing 1 post (of 1 total)
  • Author
  • #14902


    I would like to simply play a pure tone, without recording anything.
    So the idea would be to:
    1) have a vector storing the waveform for a given sound frequency (e.g. 5 kHz) and sampling rate (44100 Hz);
    2) have a loop in which a value from that vector is sequentially written using writeDAC

    I haven’t implemented step 1 yet, however I fail with step 2.
    With help from this tutorial , I connected the output of Audio Hacker to A5 and ran the following code, but it does not work.
    Only one value is printed on the serial monitor. If I remove the second for loop and just keep delayMicroseconds, values are constantly and rapidly printed but they do not seem to change according to the i-for-loop, they only fluctuate +-1 and change substantially as I change the volume.

    Any help would be very appreciated!


    #include <AudioHacker.h>

    void setup() {
    Serial.begin(115200); // connect to the serial port

    ISR(TIMER1_OVF_vect) {
    for (int i = 0; i = 4095; i++){
    int val = analogRead(A5);
    // Wait 100 ms:
    for (int j = 0; j = 100; j++){

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.