I’ve used microcontrollers in the past and am trying to get back in the game. I am working with the following example project:
I’m using a Arduino MEGA 2560 and an Adafruit MAX9814 microphone instead:
Code is below. I can get the controls to work from using a PC mic but am having trouble using the microphone from adafruit.
A few questions…
- For “#define BVSM_AUDIO_INPUT 5” ← does this map to A5 or digital pin 5? (I’ve tried hooking the “out” from the microphone to both and don’t get any different results.
I’m really stuck on getting the audio from the mircophone. Any help?
// Defines the Arduino pin that will be used to capture audio
#define BVSM_AUDIO_INPUT 5
// Defines the LED pins
#define RED_LED_PIN 6
#define YELLOW_LED_PIN 9
#define GREEN_LED_PIN 10
// Defines the constants that will be passed as parameters to
// the BVSP.begin function
const unsigned long STATUS_REQUEST_TIMEOUT = 1000;
const unsigned long STATUS_REQUEST_INTERVAL = 2000;
// Defines the size of the audio buffer
const int AUDIO_BUFFER_SIZE = 64;
// Defines the size of the receive buffer
const int RECEIVE_BUFFER_SIZE = 2;
// Initializes a new global instance of the BVSP class
BVSP bvsp = BVSP();
// Initializes a new global instance of the BVSMic class
BVSMic bvsm = BVSMic();
// Creates a buffer that will be used to read recorded samples
// from the BVSMic class
// Creates a buffer that will be used to read the commands sent
// from BitVoicer Server.
// Byte 0 = pin number
// Byte 1 = pin value
// Sets up the pin modes
// Starts serial communication at 115200 bps
// Sets the Arduino serial port that will be used for
// communication, how long it will take before a status request
// times out and how often status requests should be sent to
// BitVoicer Server.
bvsp.begin(Serial, STATUS_REQUEST_TIMEOUT, STATUS_REQUEST_INTERVAL);
// Defines the function that will handle the frameReceived
bvsp.frameReceived = BVSP_frameReceived;
// Prepares the BVSMic class timer
// Checks if the status request interval has elapsed and if it
// has, sends a status request to BitVoicer Server
// Checks if there is data available at the serial port buffer
// and processes its content according to the specifications
// of the BitVoicer Server Protocol
// Checks if there is one SRE available. If there is one,
// starts recording.
// If the BVSMic class is not recording, sets up the audio
// input and starts recording
// Checks if the BVSMic class has available samples
// Makes sure the inbound mode is STREAM_MODE before
// transmitting the stream
if (bvsp.inboundMode == FRAMED_MODE)
// Reads the audio samples from the BVSMic class
int bytesRead = bvsm.read(audioBuffer, AUDIO_BUFFER_SIZE);
// Sends the audio stream to BitVoicer Server
// No SRE is available. If the BVSMic class is recording,
// stops it.
// Handles the frameReceived event
void BVSP_frameReceived(byte dataType, int payloadSize)
// Checks if the received frame contains binary data
// 0x07 = Binary data (byte array)
if (dataType == DATA_TYPE_BINARY)
// If 2 bytes were received, process the command.
if (bvsp.getReceivedBytes(receiveBuffer, RECEIVE_BUFFER_SIZE) ==