/* Built-in LED will respond to audio. Connect headphone jack of computer to Arduino... GND wire -> Arduino GND either speaker -> Arduino A0 Do *NOT* send loud sounds into Arduino. This is because we are sometimes sending negative voltages to A0. I read somewhere that negative voltage is okay if no lower than -0.6 V, so only send quiet sound into the Arduino. When voltage is negative, analogRead() returns 0, and this only dims the LED somewhat. 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/R8MzHqkNBwo 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 = 40; // keep well below 100 else risk damaging something void setup() { pinMode(LEDpin, OUTPUT); } void loop(){ analogWrite(LEDpin, min( int(pow(2.,analogRead(sensorPin)*8/maxVolume)) ,255)); }