Toxshot44
Published © GPL3+

Clap and lights

One stage on from the last project.. a sound makes the three lights work in sequence

BeginnerProtip465
Clap and lights

Things used in this project

Hardware components

LED (generic)
LED (generic)
×5
SparkFun Electret Microphone Breakout
SparkFun Electret Microphone Breakout
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
Original project board
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
Used from another project.. two boards helps debugging
×1

Story

Read more

Schematics

Sound and Lights

Clap and the lights flash in sequence

Code

Sound and lights

Arduino
Next stage on from 'clap'
// checks to see if there is sound and if there is turns on red light
//REM make sure you check the level on the potentiometer if it doesn't work!!

int micPin = 6;   // Mic connected to pin 6
int micVal = HIGH; //HIGH is no sound, LOW is sound



void setup ()
{
  Serial.begin(9600);  
  pinMode(12, OUTPUT); //red led for sound 
  pinMode (11, OUTPUT); // green led for silence
  pinMode (micPin, INPUT) ;   //Set pin for input
  pinMode (8, OUTPUT);
  pinMode (9, OUTPUT);
  pinMode (10, OUTPUT);
}
void loop ()
{
  micVal = digitalRead (micPin) ; // senses sound
  
  if (micVal == HIGH ) // There is sound!!!
  {
    
            Serial.println ("silence");// sends 'silence' to printer
            digitalWrite(11, HIGH);//turns on green LED
            delay (5);
            digitalWrite (11, LOW);// turns off green LED
            
      } else { Serial.println ("sound");//   sends 'sound' to prinetr
            digitalWrite(12, HIGH);//turns on red LED     
            delay (5);
            digitalWrite (12, LOW);// turns off red LED
    
     
 
  digitalWrite(8, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);                       // wait for a second
  digitalWrite(8, LOW);    // turn the LED off by making the voltage LOW
  delay(500);                       // wait for a second
  digitalWrite(9, HIGH);    // turn the LED off by making the voltage LOW
  delay(500);                       // wait for a second
  digitalWrite(9, LOW);
  delay(500);
  digitalWrite(10, HIGH);
  delay(500);
  digitalWrite(10, LOW);
  }}

 


 

Credits

Toxshot44
1 project • 0 followers

Comments