hi guys, i need help with my project. i am suppose to create a mosquito anti loitering device ,by using a Arduino Uno,Honey well Is-215T Passive Infrared Motion Sensor, and a a speaker. the speaker is suppose to send out a 16.4Khz noise which is only audible to Human at the age of 15-25,after the Is-215T infrared sensor have sense some one around it range for more than 30sec. i would like to know whether there are any mistake in my program. thanks!
int inputPin = 2; // declare the pir sensor pin number
int speakerPin =10; // declare the speaker pin number
int val =0; //variable for reading the pin status
int pirState =LOW; // assuming no motion detected
int ledPin = 13; // declare the led pin number
void setup()
{
pinMode(ledPin, OUTPUT); //set the LED as output
pinMode(inputPin, INPUT);// set the sensor as input
pinMode(speakerPin, OUTPUT);//set the speaker pin mode to output
Serial.begin(9600);
}
void loop()
{
val = digitalRead(inputPin);//read input value
if (val == HIGH)//check if the input is HIGH
{
digitalWrite(ledPin, HIGH);//turn LED ON
playTone(300, 16400);
delay(30000);
if (pirState == LOW)//we have just turned on
{
Serial.println("Motion detected!");//print as an ASCII-encoded label
pirState = HIGH;
}
}
else
{
digitalWrite(ledPin, LOW); //turn LED OFF
playTone(0, 0);
delay(300);
if (pirState == HIGH)//we have just turn off
{
Serial.println("Motion ended!");//print as an ASCII-encoded label
pirState = LOW;
}
}
}
void playTone(long duration, int freq)
{
duration *=1000;
int period = (1.0/freq)* 1000000;
long elapsed_time = 0;//elapsed time,the period of time
while (elapsed_time < duration)
{
digitalWrite(speakerPin, HIGH);
delayMicroseconds(period / 2);// to find time High
digitalWrite(speakerPin, LOW);
delayMicroseconds(period / 2);//to find time High
elapsed_time += (period);
}
}
How did you confirm the sensitivity to a single Mosquito they are not large enough to be much of an IR emitter and to the best of my limited knowledge exothermic in growth or digestion of food...
IMO your test conditions are questionable... Better, I think to detect the noise generated by their wings in flight...
Docedison:
How did you confirm the sensitivity to a single Mosquito they are not large enough to be much of an IR emitter and to the best of my limited knowledge exothermic in growth or digestion of food...
IMO your test conditions are questionable... Better, I think to detect the noise generated by their wings in flight...
Doc
Dear docedison, although the device is call mosquito anti loitering device, it has nothing to do with mosquito. It is a security control system use to prevent teenager to loiter around private property
Actually what you know is that the sensor was active when you checked 30 seconds ago. Was it active for a fraction of a second ? Is it still active ? Who knows ?
Actually what you know is that the sensor was active when you checked 30 seconds ago. Was it active for a fraction of a second ? Is it still active ? Who knows ?
Not so Paul, in this case... that pirState status test is inside a val=high "if"
what about high traffic areas where people will continue to pass by ?
it would need to sense a no-motion and then re-set to detect the gaps between people walking
If my 10 year old is any indication, you can set the 'no-motion' gap to about .01ms
Also, the constant sound would be annoying and quickly discovered. Think about variable timing.
Most professional "Perimeter denial" devices use a combination of both doppler radar and IR sensors...
I've designed Perimeter Denial devices with a 500 meter range using a 75 KG body mass as the doppler range and the IR function was for Hot bodies... like automobiles... or close body radiation
The Mosquito device looks like a short range device working under the assumption that radiated IR from a human sized "model" was close enough to exceed the normal ambient IR radiation of a hot day or night where the ambient radiation is greater than the ~ 86 deg average body radiation of a fully clothed body...
Hi guys, i am suppose to create a anti loitering alarm sensor.Does anyone know how should i code my programming so that my Speaker will only sound ,after my PIR sensor have sense a motion(HIGH) more than 30Sec. And if the motion was gone(LOW) in between the 30 sec the speaker will not sound
Sorry I can't be of too much help, but this question has me wondering as well:
Can the PIR sensor detect motion for lengths of time? I think it only turns HIGH/LOW, so you would have to read the value from it multiple times over 30 seconds, and make sure it's HIGH every time.
So, after say 10 HIGH results with a delay of 3 seconds each, you'll know there was motion for 30 seconds - then you can sound your buzzer...
Edit: BulldogLowell's time difference recommendation is better, so never mind me.