Hi,
I have two PIR motion sensors and a microphone attached to my Ardunio Uno and my goal is to have a green LED light when there is no sound detected and for that LED to turn off and have a red LED turn on when when there is sound detected. The same thing for the motion sensors, but if either of them sense, the LED. I had it working perfectly for a while, and then touched someone I suppose and now its not working.
The sound works perfectly by itself, but when I add the PIRs, it says continuously stays green.
I have not gotten the PIRs to work with or without the other sensor.
I've tried switching wires, switching the PIRs, and changing the voltage pins, but no prevail.
int soundSensor = 9;
int motionSensor1= 4;
int motionSensor2 = 3;
int mrl = 1; //mrl- MotionSensor Red LED//
int mgl = 2; //mgl= MotionSensor Green LED//
int srl = 8; //srl= SoundSensor Red LED//
int sgl = 10; //sgl= SoundSensor Green LED//
int in = 6;
int out = 7;
void setup()
{
pinMode(soundSensor, INPUT);
pinMode(motionSensor1, INPUT);
pinMode(motionSensor2, INPUT);
pinMode(srl, OUTPUT);
pinMode(sgl, OUTPUT);
pinMode(mrl, OUTPUT);
pinMode(mgl, OUTPUT);
pinMode(in, OUTPUT);
pinMode(out, OUTPUT);
}
void loop()
{
int statusSound = digitalRead(soundSensor);
if (statusSound == 1)
{
digitalWrite(sgl, LOW);
digitalWrite(srl, HIGH);
delay(3000);
}
else
{
digitalWrite(srl, LOW);
}
if (statusSound == 0)
{
digitalWrite(srl, LOW);
digitalWrite(sgl, HIGH);
}
int motionStatus1 = digitalRead(motionSensor1);
int motionStatus2 = digitalRead(motionSensor2);
if (motionStatus1 || motionStatus2 == 1)
{
digitalWrite(mgl, LOW);
digitalWrite(mrl, HIGH);
digitalWrite(mgl, HIGH);
delay(3000);
}
else
digitalWrite(mrl, LOW);
if (motionStatus1 || motionStatus2 == 0)
{
digitalWrite(mrl, LOW);
digitalWrite(mgl, HIGH);
}
Any help/ideas are super apperciated!
Thanks,
Emma