I’m trying to build an autonomous robot that utilizes a RedBot, a Parallax ultrasonic sensor, and a Radioshack/Parallax PIR sensor.
The goals -
Autonomous (collision aversion) driving, via ultrasonic sensor - Done
Stop movement every 5 seconds - Done
Once movement is stopped, turn a servo (i.e. a tank turret) to 20 degrees, hold, move to 70 degrees, hold, move to 160 degrees, hold, then back to 70 degrees (forward facing) - Done
Every time the servo holds at a position (20 to 70 to 160 to 70) check for motion on the PIR sensor - Problems
Simply put, I am not getting reliable detection on the PIR sensor. It either gives me a false reading, often times at the same servo position, or it just won’t detect anything; even if I am having a full body seizure ten inches away from the sensor. However, when I use the PIR sensor on its own in a different sketch (with basic example code), it works flawlessly. Actually, it works too good! I was surprised to find the PIR sensor can actually detect when I smile! I am honestly just not sure what to do at this point.
I attached the code. I hope it is legible; for I am a beginner and I probably do not follow ideal coding practices.
I’ve yet to look at your code (will later) but most PIR’s incorporate a filter to eliminate false alarms due to the sun setting/rising and other such conditions. How long are you waiting at each position for that filtering to settle ? It might have to be several seconds.
Mee_n_Mac:
I’ve yet to look at your code (will later) but most PIR’s incorporate a filter to eliminate false alarms due to the sun setting/rising and other such conditions. How long are you waiting at each position for that filtering to settle ? It might have to be several seconds.
Thanks for the response.
That’s sort of what I assumed, so I put a delay of 2 seconds at each position. I have no idea if that is long enough.
Perhaps tomorrow I’ll re-awaken a brain cell or 3 and figure out a way to figure out what’s happening. That will likely involve some testing on your part. Are you willing ?
Just to be sure I’ve understood your situation … you have the PIR mounted on some “lazy susan” turntable, controlled by a servo. When you position the turntable at X deg, and wait Y sec, then toss a ‘red flag’ in clear view of the PIR … it doesn’t detect whereas it does when not moved to X deg ?
‘red flag’ = think … running of the bulls in Pamplona. You’d see 'em.
So I tried a delay of 6 seconds rather than 2, and it seems to be working!
The sensor provided reliable measurements almost 90% of the time and it seems that the sensor actually works better at detecting movement < 20 centimeters away. So, it could easily be 100% accurate.
If I ever get this thing to do what I ultimately want (launching bottle rockets at IR sources :lol: :lol: ) than I will definitely share the results.