Microphone Lights LED

by adamgold18 in Circuits > LEDs

2699 Views, 9 Favorites, 0 Comments

Microphone Lights LED

In our modern day world, sound and light are what makes up society. Everywhere you go light and sound are present, whether in Times Square or at a concert both are there. In an attempt to combine the two, a code was made where LEDs were turned on based on sound frequencies.

Parts

1. Arduino

2. Wires

3. Microphone

4. 7 LEDs

5. Breadboard

6. Resistor

*pictures are in order of parts

Coding

After the idea of lighting LEDs based on sound was agreed on, a code was needed. In order to make sure each light was independently accounted for a code, we needed to give each light a code as to when they should light up.

Based on the sound the microphone measures the lights would respond accordingly. The sound range of our lights varies from 5-1000. This means that every light would light at a certain point between 5-1000. Each light was programmed to their own 'off and on' code.
The code goes as such:


void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(A0, INPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(7, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);

}

void loop() {
// put your main code here, to run repeatedly:
int val = analogRead(A0);
Serial.println(val);


if (val > 750) {
digitalWrite(6, HIGH);
}
if (val < 750) {
digitalWrite(6, LOW);
}
if (val > 850){
digitalWrite(5, HIGH);
}
if (val < 850) {
digitalWrite(5, LOW);
}
if (val > 900) {
digitalWrite(7, HIGH);
}
if (val < 900) {
digitalWrite(7, LOW);
}
if (val > 1000) {
digitalWrite(3, HIGH);
}
if (val < 1000) {
digitalWrite(3, LOW);
}
if (val > 5) {
digitalWrite(2, HIGH);
}
if (val < 5) {
digitalWrite(2, LOW);
}
if (val > 100) {
digitalWrite(1, HIGH);
}
if (val < 100) {
digitalWrite(1, LOW);
}
if (val > 200) {
digitalWrite(3, HIGH);
}
if (val < 200) {
digitalWrite(3, LOW);
}
if (val > 600) {
digitalWrite(4, HIGH);
}
if (val < 600) {
digitalWrite(4, LOW);
}
}

Building

In order to make sure the code and board function perfectly together, it must be built accordingly.

*referring to picture 1
Explanation: Each wire must correspond one LED and the Arduino.

*referring to picture 2
Explanation: Be sure to include a resistor

*referring to pictures 3 and 4
Each wire goes to a specific place on the Arduino so make sure it is followed exactly as the picture shows