/* * 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 #include #include #include #include #include #ifdef __AVR__ #include #endif #define PIN 22 #define NUMPIXELS 12 Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); #define DELAYVAL 500 // 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 const int myInput = AUDIO_INPUT_LINEIN; const int PWMpin1=20; void setup() { // Audio connections require memory to work. For more // detailed information, see the MemoryAndCpuUsage example AudioMemory(12); pinMode(PWMpin1, OUTPUT); // Enable the audio shield, select input, and enable output sgtl5000_1.enable(); sgtl5000_1.inputSelect(myInput); sgtl5000_1.volume(0.5); analogWriteFrequency(PWMpin1, 40000); analogWrite(PWMpin1, 127); //initialze at 50% duty cycle pixels.begin(); Serial.begin(9600); } elapsedMicros volmsec=0; int counter = 0; void loop() { // every 50 us, adjust the volume if (volmsec >= 20000) { float vol = analogRead(15); vol = vol / 1023.0; //audioShield.volume(vol); // <-- uncomment if you have the optional volmsec = 0; // volume pot on your audio shield if (counter%2==0) { for(int i=0; i 100) { int audio_analog = analogRead(A7); int mapped = map(audio_analog, -127, 127, 0, 255); analogWrite(PWMpin1, mapped); Serial.println(mapped); } }