Sound Chasing / Presets

Hi Everyone, im currently building a LED dancefloor. I am using WS2811 5V LEDS and a arduino uno.

I have some code working from a premade example using pin 6.

I am wondering is their a way to have a two way switch that one way i can connect a microphone and the leds go to the sound or the second way plays a preset animation of light chases.

Im really new to Arduino so please bare with me and also many thanks in advance for any help offered.

Very easy.

byte  modeSwitch = 3; // pin D3 as an example
void setup(){
pinMode (modeSwitch, INPUT_PULLUP);
Serial.begin (9600);
}
void loop()
if (digitalRead(modeSwitch) == LOW){
Serial.println ("modeSwitch is low");
}
else {
Serial.println ("modeSwitch is high");
}
delay (200); // limit prints to 5 per second
}

Have your sketch do the different program paths depending on the switch state.

It's important you understand you can't connect an analog audio signal direct to an Arduino analog pin. Audio signals are AC but Arduino analog pins are DC only. The negative part of an AC signal would damage an Arduino pin.

There is a chip called MSGEQ7 which can help the Arduino to analyse an audio signal, measuring the signal in 7 frequency bands. The chip is available in various shields or as a bare chip if you prefer to build your own circuit. This chip is designed to accept an analog AC line-level signal.