Read samples from analog input ADC and outputs to DAC,outputs to speaker, like a karaoke machine lol

Dependencies:   mbed

main.cpp

Committer:
mbed2f
Date:
2011-05-28
Revision:
0:32b3a9352bd2

File content as of revision 0:32b3a9352bd2:

#include "mbed.h"
 
/* ADC for the microphone/input, DAC for the speaker/output */
AnalogIn mic(p19);
AnalogOut speaker(p18);
 
#define NUM_SAMPLES   15000
unsigned short buffer[NUM_SAMPLES];
 
int main()
{
    int i;
    for (i = 0; ; ) // infinite loop
    {
        /* read mike */
        buffer[i] = mic.read_u16();
        /* Write to speaker */
        speaker.write_u16(buffer[i]);
        /* Increment index and wrap around */
        i = (i+1) % NUM_SAMPLES;
    }
}