| // Dial Tone (DTMF) decoding example. | // Dial Tone (DTMF) decoding example. | ||||
| // | // | ||||
| // The audio with dial tones is connected to analog input A0, | |||||
| // The audio with dial tones is connected to analog input A2, | |||||
| // without using the audio shield. See the "DialTone_DTMF" | // without using the audio shield. See the "DialTone_DTMF" | ||||
| // example for using the audio shield. | // example for using the audio shield. | ||||
| // | |||||
| // This example code is in the public domain. | |||||
| #include <Audio.h> | #include <Audio.h> | ||||
| #include <Wire.h> | #include <Wire.h> | ||||
| // Create the Audio components. These should be created in the | // Create the Audio components. These should be created in the | ||||
| // order data flows, inputs/sources -> processing -> outputs | // order data flows, inputs/sources -> processing -> outputs | ||||
| // | // | ||||
| AudioInputAnalog audioIn(A0); | |||||
| AudioInputAnalog audioIn; | |||||
| AudioAnalyzeToneDetect row1; // 7 tone detectors are needed | AudioAnalyzeToneDetect row1; // 7 tone detectors are needed | ||||
| AudioAnalyzeToneDetect row2; // to receive DTMF dial tones | AudioAnalyzeToneDetect row2; // to receive DTMF dial tones | ||||
| AudioAnalyzeToneDetect row3; | AudioAnalyzeToneDetect row3; | ||||
| // Create Audio connections between the components | // Create Audio connections between the components | ||||
| // | // | ||||
| AudioConnection c01(audioIn, 0, row1, 0); | |||||
| AudioConnection c02(audioIn, 0, row2, 0); | |||||
| AudioConnection c03(audioIn, 0, row3, 0); | |||||
| AudioConnection c04(audioIn, 0, row4, 0); | |||||
| AudioConnection c05(audioIn, 0, column1, 0); | |||||
| AudioConnection c06(audioIn, 0, column2, 0); | |||||
| AudioConnection c07(audioIn, 0, column3, 0); | |||||
| AudioConnection patchCord1(audioIn, 0, row1, 0); | |||||
| AudioConnection patchCord2(audioIn, 0, row2, 0); | |||||
| AudioConnection patchCord3(audioIn, 0, row3, 0); | |||||
| AudioConnection patchCord4(audioIn, 0, row4, 0); | |||||
| AudioConnection patchCord5(audioIn, 0, column1, 0); | |||||
| AudioConnection patchCord6(audioIn, 0, column2, 0); | |||||
| AudioConnection patchCord7(audioIn, 0, column3, 0); | |||||
| // pins where the 7 segment LEDs are connected | // pins where the 7 segment LEDs are connected | ||||
| const int sevenseg_a = 17; // aaa | const int sevenseg_a = 17; // aaa | ||||
| const int sevenseg_b = 9; // f b | const int sevenseg_b = 9; // f b | ||||
| const int sevenseg_c = 11; // f b | const int sevenseg_c = 11; // f b | ||||
| const int sevenseg_d = 12; // ggg | const int sevenseg_d = 12; // ggg | ||||
| const int sevenseg_e = 15; // e c | |||||
| const int sevenseg_f = 16; // e c | |||||
| const int sevenseg_e = 14; // e c | |||||
| const int sevenseg_f = 15; // e c | |||||
| const int sevenseg_g = 10; // ddd | const int sevenseg_g = 10; // ddd | ||||
| // Dial Tone (DTMF) decoding example. | |||||
| // | |||||
| // The audio with dial tones is connected to audio shield | |||||
| // Left Line-In pin. Dial tone output is produced on the | |||||
| // Line-Out and headphones. | |||||
| // | |||||
| // Use the Arduino Serial Monitor to watch for incoming | |||||
| // dial tones, and to send digits to be played as dial tones. | |||||
| // | |||||
| // This example code is in the public domain. | |||||
| #include <Audio.h> | #include <Audio.h> | ||||
| #include <Wire.h> | #include <Wire.h> | ||||
| #include <SPI.h> | #include <SPI.h> | ||||
| AudioAnalyzeToneDetect column1; | AudioAnalyzeToneDetect column1; | ||||
| AudioAnalyzeToneDetect column2; | AudioAnalyzeToneDetect column2; | ||||
| AudioAnalyzeToneDetect column3; | AudioAnalyzeToneDetect column3; | ||||
| AudioSynthWaveform sine1(AudioWaveformSine); // 2 sine wave | |||||
| AudioSynthWaveform sine2(AudioWaveformSine); // to create DTMF | |||||
| AudioSynthWaveformSine sine1; // 2 sine wave | |||||
| AudioSynthWaveformSine sine2; // to create DTMF | |||||
| AudioMixer4 mixer; | AudioMixer4 mixer; | ||||
| AudioOutputI2S audioOut; | AudioOutputI2S audioOut; | ||||
| // Create Audio connections between the components | // Create Audio connections between the components | ||||
| // | // | ||||
| AudioConnection c01(audioIn, 0, row1, 0); | |||||
| AudioConnection c02(audioIn, 0, row2, 0); | |||||
| AudioConnection c03(audioIn, 0, row3, 0); | |||||
| AudioConnection c04(audioIn, 0, row4, 0); | |||||
| AudioConnection c05(audioIn, 0, column1, 0); | |||||
| AudioConnection c06(audioIn, 0, column2, 0); | |||||
| AudioConnection c07(audioIn, 0, column3, 0); | |||||
| AudioConnection c10(sine1, 0, mixer, 0); | |||||
| AudioConnection c11(sine2, 0, mixer, 1); | |||||
| AudioConnection c12(mixer, 0, audioOut, 0); | |||||
| AudioConnection c13(mixer, 0, audioOut, 1); | |||||
| AudioConnection patchCord01(audioIn, 0, row1, 0); | |||||
| AudioConnection patchCord02(audioIn, 0, row2, 0); | |||||
| AudioConnection patchCord03(audioIn, 0, row3, 0); | |||||
| AudioConnection patchCord04(audioIn, 0, row4, 0); | |||||
| AudioConnection patchCord05(audioIn, 0, column1, 0); | |||||
| AudioConnection patchCord06(audioIn, 0, column2, 0); | |||||
| AudioConnection patchCord07(audioIn, 0, column3, 0); | |||||
| AudioConnection patchCord10(sine1, 0, mixer, 0); | |||||
| AudioConnection patchCord11(sine2, 0, mixer, 1); | |||||
| AudioConnection patchCord12(mixer, 0, audioOut, 0); | |||||
| AudioConnection patchCord13(mixer, 0, audioOut, 1); | |||||
| // Create an object to control the audio shield. | // Create an object to control the audio shield. | ||||
| // | // | ||||
| // Enable the audio shield and set the output volume. | // Enable the audio shield and set the output volume. | ||||
| audioShield.enable(); | audioShield.enable(); | ||||
| audioShield.volume(0.75); | |||||
| audioShield.volume(0.5); | |||||
| while (!Serial) ; | while (!Serial) ; | ||||
| delay(100); | delay(100); |
| /* | |||||
| * A simple hardware test which receives audio on the A2 analog pin | |||||
| * and sends it to the PWM (pin 3) output and DAC (A14 pin) output. | |||||
| * | |||||
| * This example code is in the public domain. | |||||
| */ | |||||
| #include <Audio.h> | #include <Audio.h> | ||||
| #include <Wire.h> | #include <Wire.h> | ||||
| #include <SPI.h> | #include <SPI.h> | ||||
| #include <SD.h> | #include <SD.h> | ||||
| #include "utility/pdb.h" | |||||
| // GUItool: begin automatically generated code | // GUItool: begin automatically generated code | ||||
| AudioInputAnalog adc1; //xy=161,80 | AudioInputAnalog adc1; //xy=161,80 |
| /* | |||||
| * A simple hardware test which receives audio from the audio shield | |||||
| * Line-In pins and send it to the Line-Out pins and headphone jack. | |||||
| * | |||||
| * This example code is in the public domain. | |||||
| */ | |||||
| #include <Audio.h> | #include <Audio.h> | ||||
| #include <Wire.h> | #include <Wire.h> | ||||
| #include <SPI.h> | #include <SPI.h> | ||||
| #include <SD.h> | #include <SD.h> | ||||
| const int myInput = AUDIO_INPUT_LINEIN; | |||||
| //const int myInput = AUDIO_INPUT_MIC; | |||||
| // Create the Audio components. These should be created in the | |||||
| // order data flows, inputs/sources -> processing -> outputs | |||||
| // | |||||
| //AudioInputAnalog analogPinInput(16); // analog A2 (pin 16) | |||||
| AudioInputI2S audioInput; // audio shield: mic or line-in | |||||
| AudioOutputI2S audioOutput; // audio shield: headphones & line-out | |||||
| AudioOutputPWM pwmOutput; // audio output with PWM on pins 3 & 4 | |||||
| // GUItool: begin automatically generated code | |||||
| AudioInputI2S i2s1; //xy=200,69 | |||||
| AudioOutputI2S i2s2; //xy=365,94 | |||||
| AudioConnection patchCord1(i2s1, 0, i2s2, 0); | |||||
| AudioConnection patchCord2(i2s1, 1, i2s2, 1); | |||||
| AudioControlSGTL5000 sgtl5000_1; //xy=302,184 | |||||
| // GUItool: end automatically generated code | |||||
| // Create Audio connections between the components | |||||
| // | |||||
| AudioConnection c1(audioInput, 0, audioOutput, 0); | |||||
| AudioConnection c2(audioInput, 1, audioOutput, 1); | |||||
| AudioConnection c5(audioInput, 0, pwmOutput, 0); | |||||
| // Create an object to control the audio shield. | |||||
| // | |||||
| AudioControlSGTL5000 audioShield; | |||||
| const int myInput = AUDIO_INPUT_LINEIN; | |||||
| //const int myInput = AUDIO_INPUT_MIC; | |||||
| void setup() { | void setup() { | ||||
| // detailed information, see the MemoryAndCpuUsage example | // detailed information, see the MemoryAndCpuUsage example | ||||
| AudioMemory(12); | AudioMemory(12); | ||||
| // Enable the audio shield and set the output volume. | |||||
| audioShield.enable(); | |||||
| audioShield.inputSelect(myInput); | |||||
| audioShield.volume(0.6); | |||||
| // Enable the audio shield, select input, and enable output | |||||
| sgtl5000_1.enable(); | |||||
| sgtl5000_1.inputSelect(myInput); | |||||
| sgtl5000_1.volume(0.5); | |||||
| } | } | ||||
| elapsedMillis volmsec=0; | elapsedMillis volmsec=0; | ||||
| if (volmsec > 50) { | if (volmsec > 50) { | ||||
| float vol = analogRead(15); | float vol = analogRead(15); | ||||
| vol = vol / 1023.0; | vol = vol / 1023.0; | ||||
| audioShield.volume(vol); | |||||
| volmsec = 0; | |||||
| //audioShield.volume(vol); // <-- uncomment if you have the optional | |||||
| volmsec = 0; // volume pot on your audio shield | |||||
| } | } | ||||
| } | } | ||||