/* Built-in LED will respond to audio. This code and electrical setup is more complicated than my other one because I want to capture negative-voltage audio signal as well. Connect headphone jack of computer to Arduino... computer audio GND -> Arduino GND pin computer audio -> 2 5000-ohm resistors in series -> Arduino 5V pin Arduino A0 pin -> where the 2 resistors connect Both resistors have the same resistance. You have created a voltage divider that outputs a signal more-or-less centered at 2.5 V! There will be a signal reduction at A0 pin by a factor of 2. Using large resistances is needed to limit current; large current might have unwanted effects on the computer's headphone jack?? Using a resistance larger than 5k risks the Arduino's ADC not reacting fast enough. To maximize the output signal peak-to-peak instead of centering the voltage, do not set the resistances to be equal, but set the resistor connected to 5V pin to be (5 V)/Vmax times the other resistance, where Vmax is amplitude of the computer's output (1 V is a safe bet). Instead, you may wish to look into using an op-amp... https://www.youtube.com/watch?v=lJDjWZqhpVc&list=PLSQl0a2vh4HCLqA-rhMi_Z_WnBkD3wUka https://youtu.be/kqCV-HGJc6A I like an op-amp because, ideally, no current flows into it from the computer. Probably no important advantages. You can send the computer's (original) signal to powered speakers while Arduino samples! The code will use the first fraction of a second of time to find the average signal. My computer's audio acquires a large resistance if audio has not played in 30 seconds (muting an application's audio is considered "playing", but pausing the audio is considered "not playing"), which causes the voltage at the A0 pin to be artificially large. So, when the Arduino is turned on, be sure to have the audio in a playing mode. You cannot sample at more than 10,000 Hz according to https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/ Simpler songs work better. For example, parts of this one is great! https://youtu.be/adudqtq2gBw Ludovico Einaudi - Oltremare (c) 2018 Bradley Knockel */ int const sensorPin = 0; // set analog pin to be A0 const int LEDpin = 13; // built-in LED // set the max volume (larger if louder sounds are sent to Arduino) const float maxVolume = 75; int zero; // compare all reading at A0 to this void setup() { pinMode(LEDpin, OUTPUT); // calculate zero long int sum=0; int iterations = 5000; for(int i=0;i