int SoundSensor=A0;
int ledPin1=13;
int ledPin2=7;
int inputPin=13;
int pirState=LOW;
int val=0;
int speakerPin =12;
int numTones=12;
int tones=294;
void setup()
{
pinMode(13,OUTPUT);
pinMode(7,OUTPUT);
pinMode(inputPin,INPUT);
pinMode(12,OUTPUT);
Serial.begin(9600);
pinMode(A0.INPUT);
pinMode(A1,INPUT);
}
void loop()
{
int level=analogRead(SoundSensor);
Serial.println(level);
if(level<=200)
{
Serial.println("BOY");
digitalWrite(speakerPin,HIGH);
delay(300);
}
else
{
Serial.println("GIRL");
digitalWrite(speakerPin,HIGH);
delay(100);
digitalWrite(speakerPin,HIGH);
delay(100);
}
val=digitalRead(inputPin);
if(val==HIGH)
{
digitalWrite(ledPin1,HIGH);
digitalWrite(ledPin2.LOW);
tone(speakerPin,294);
Serial.println("COME");
delay(500);
}
else
{
digitalWrite(ledPin1,LOW);
digitalWrite(ledPin2,LOW);
noTone(speakerPin);
Serial.println("NOBODY");
delay(1000);
}
}
|