For Arduino Due
Simple Sine Wave Generation Example:
This example demonstrates simple generation of a sine wave & optionally broadcasting the audio via radio
Send a number 1 or 2 over Serial to change frequency, +/- to adjust volume
- Note
- This code depends on radio.h located in the same directory.
void DACC_Handler(void) {
}
void setup() {
Serial.begin(115200);
Serial.println("Analog Audio Begin");
arraysetup();
}
char shiftVal = 0;
uint32_t dispTimer = 0;
void loop() {
if (Serial.available()) {
char d = Serial.read();
switch (d) {
case '1': arraysetup(); break;
case '2': arraysetup2(); break;
case '+': shiftVal > 0 ? --shiftVal : NULL; break;
case '-': shiftVal < 7 ? ++shiftVal : NULL; break;
default: arraysetup(); break;
}
Serial.print("Volume: ");
Serial.print(7 - shiftVal, DEC);
Serial.println("/7");
}
}
void arraysetup(void) {
}
void arraysetup2(void) {
}
uint8_t dacBuffer[MAX_BUFFER_SIZE]
void setSampleRate(uint32_t sampRate=0, bool stereo=true)
void feedDAC(uint8_t dacChannel=0, uint32_t samples=MAX_BUFFER_SIZE, bool startInterrupts=false)
void begin(bool enADC, bool enDAC)