📬❄️📦Adafruit Holiday Shipping Deadlines 2019: Please place all UPS 3 Day orders by 11am ET Friday December 13 📬❄️📦
0

Using a PIR sensor to start a timer
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Using a PIR sensor to start a timer

by Preston727 on Sun Oct 29, 2017 3:34 am

Hello!

This is my first post, and I'm rather new to electronics and these products. My goal is to use the PIR sensor (https://www.adafruit.com/product/189) that upon an object moving, starts a timer. Also, what product would I use to then stop the timer at the end point? I was thinking the one side of the IR break-beam sensor (https://www.adafruit.com/product/2168) would be set up from start at 0 ft mark and the other side IR break-beam to end point at a 10ft mark. The PIR sensor would sense the motion, to start a timer (https://www.adafruit.com/product/813), then the IR break-beam sensor would stop the timer once the object has crossed pass that 10 ft end point mark. If that works, am i able to use this board as a tester (https://www.adafruit.com/product/3314)? Does that make sense? thanks kindly for your time, help, and guidance.

Preston727
 
Posts: 29
Joined: Sun Oct 29, 2017 3:28 am

Re: Using a PIR sensor to start a timer

by adafruit_support_bill on Sun Oct 29, 2017 6:31 am

My goal is to use the PIR sensor (https://www.adafruit.com/product/189) that upon an object moving, starts a timer.

What kind of object are we talking about? A PIR sensor senses changes in IR radiation. It is optimized for the IR wavelength range of warm-blooded mammals. So unless we are talking people or animals, the PIR is not the sensor to use.

adafruit_support_bill
 
Posts: 75299
Joined: Sat Feb 07, 2009 10:11 am

Re: Using a PIR sensor to start a timer

by Preston727 on Sun Oct 29, 2017 3:00 pm

I would say the object could be either a human or animal. But my main concern, is should I use the IR break-beam sensor or the PIR sensor? Also, would that timer I noted in the last post be of use the way I described it? Or not? Thanks! This building stuff is fun!

Preston727
 
Posts: 29
Joined: Sun Oct 29, 2017 3:28 am

Re: Using a PIR sensor to start a timer

by franklin97355 on Sun Oct 29, 2017 6:38 pm

I would use break beam at both ends of the path. You also need something to do the timing like a Uno, the Metro or Feather.

franklin97355
 
Posts: 21362
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Using a PIR sensor to start a timer

by Preston727 on Sun Oct 29, 2017 6:41 pm

Franklin,

Thanks so much for your info! I'll try that!

I have found each of those by name, but i'm not sure what to do with them, or how they will start a timer once the break-beam is broken...I was looking at a simple timer to go along with the ir break-beam sensor at each end... which would you recommend or are there tutorials in which I can learn about how to do that? Thanks.

Preston727
 
Posts: 29
Joined: Sun Oct 29, 2017 3:28 am

Re: Using a PIR sensor to start a timer

by adafruit_support_bill on Sun Oct 29, 2017 9:05 pm

The Ardino has a millis() function: https://www.arduino.cc/en/Reference/Millis
This can be used for millisecond level timing. Simply call millis() when the first sensor is tripped. Then call it again when the second sensor is tripped. Subtracting the first time from the second time will give you the elapsed time in milliseconds.

adafruit_support_bill
 
Posts: 75299
Joined: Sat Feb 07, 2009 10:11 am

Re: Using a PIR sensor to start a timer

by Preston727 on Sun Oct 29, 2017 11:25 pm

Ok, I don't know the type of language you're speaking and I mean that in the nicest way possible. I just am REALLY new to electronics. So, you're saying that, once I have the IR break-beam sensors set up at each end point 10 ft away from one another. The object starts moving to break the first beam which initiates the milli timer at that same moment, then the object continues moving to the 10ft end point, crossing that beam to then shut off that timer at the same instance it crosses the last beam. Lets say taking it 10 seconds to get from start to finish, and the milli you're speaking of will be able to do that? I apologize for being lame and possibly not using the proper wording, but I'm searching youtube, as well as on here to learn as much as possible about how to achieve what i'm trying to do. Thanks for the patience and help everyone!

Preston727
 
Posts: 29
Joined: Sun Oct 29, 2017 3:28 am

Re: Using a PIR sensor to start a timer

by franklin97355 on Sun Oct 29, 2017 11:42 pm

Try Googling "learn Arduino" for starters. Check out some of these videos.

franklin97355
 
Posts: 21362
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Using a PIR sensor to start a timer

by Preston727 on Sun Oct 29, 2017 11:45 pm

Ok, I check them out, but nothing specific on what i'm trying to do: here's my goal: I'm trying to have a race between students. I have the Arduino Uno Budget pack coming along with a PIR motion sensor, a IR break-beam sensor, and a 4 segment LCD display. I know I'll need to find a stopwatch code in the library, in order to program but was wondering if the sensor I have coming can be set up 15 to 20 ft away from, I would assume I just need 15 feet of wire or so, or what sensor to use or if these that I have on order will work the 15-20ft distance away. Could I use the PIR motion sensor to start the timer at 0 feet, the beginning of the race, then when they cross the finish line, 15 to 20 feet away, they will break the IR break-beam sensor to stop the timer. Each student will go one at a time and they'll race maybe 15-20 ft max. I'd like to be able to see their time on that LCD display for 30 to 60 seconds, and then they can write it down, then reset and the next student will be up. Thanks.

Preston727
 
Posts: 29
Joined: Sun Oct 29, 2017 3:28 am

Re: Using a PIR sensor to start a timer

by adafruit_support_bill on Wed Nov 01, 2017 5:57 am

I know I'll need to find a stopwatch code in the library

As explained earlier in this thread, the millis() function from the Arduino library gives you millisecond level timing. And if you search, there are dozens of examples of stopwatch applications for the Arduino using millis(). Here is just one: https://playground.arduino.cc/Code/Stopwatch
was wondering if the sensor I have coming can be set up 15 to 20 ft away from, I would assume I just need 15 feet of wire or so, or what sensor to use or if these that I have on order will work the 15-20ft distance away.

Which sensor and 15 - 20 feet from what? For a break-beam or PIR, 15 - 20 feet from the sensor to the Arduino should not be a problem.
Could I use the PIR motion sensor to start the timer at 0 feet, the beginning of the race,

Not with any degree of accuracy. These devices have a 120 degree field of view. You are better off with a break-beam at both ends.

adafruit_support_bill
 
Posts: 75299
Joined: Sat Feb 07, 2009 10:11 am

Re: Using a PIR sensor to start a timer

by Preston727 on Wed Nov 01, 2017 6:20 am

adafruit_support_bill,

I know it was explained earlier in the thread mate, I've read them all and looked into them ever since first posting but thanks for repeating it as I'm new to this and I'm sure it'll help. I have searched and have found a few different ones millis() to use.

"As explained earlier in the thread" I mentioned which sensors I was using and where I wanted to use them. 1st the PIR motion sensor in the beginning at 0 ft, which is the start. Then, I wanted the break beam IR sensor to be placed 20ft away in a straight line, so when I cross it, it trips the laser which signals the timer to stop counting. an example could be like a 100 meter race but I'm only going 20ft. Then, when I'm done moving across that 20ft, I want to see the time on the LCD display, which I already noted too, "explained earlier in the thread" in my first post. It's a simple 7 segment LCD display. However, I now know, that using a PIR motion sensor wouldn't be ideal to start things off, which is why i'm going to order another IR BB sensor to start and send the PIR motion sensor back.

Lastly, I'm going to set up the last sensor 15 to 20 ft away from the first sensor. Though because I'm new to this kind of stuff, I am not sure if running a wire 15 - 20 feet to the last set of IR BB sensors is optimal, or if there's a better way. Simply asking to learn more and broaden the possibilities.

Preston727
 
Posts: 29
Joined: Sun Oct 29, 2017 3:28 am

Re: Using a PIR sensor to start a timer

by adafruit_support_bill on Wed Nov 01, 2017 6:37 am

Phrases like "the sensor I have coming" are vague. And our answers can only be as correct as the questions are precise

Having a 15-20 foot wire between a break-beam sensor and an Arduino should not be a problem. Having that distance between the transmitter and receiver of the break-beam would be a problem. And if your course will be set up outside, ambient IRlevels could also be a problem. You may find it necessary to shroud the receivers to block out ambient IR.

adafruit_support_bill
 
Posts: 75299
Joined: Sat Feb 07, 2009 10:11 am

Re: Using a PIR sensor to start a timer

by Preston727 on Wed Nov 01, 2017 4:22 pm

Ok, Thanks!

Preston727
 
Posts: 29
Joined: Sun Oct 29, 2017 3:28 am

Please be positive and constructive with your questions and comments.