Adafruit Ir break beam sensor help.

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
AlexMaven
 
Posts: 2
Joined: Sun Sep 11, 2022 7:09 pm

Adafruit Ir break beam sensor help.

Post by AlexMaven »

So I plan to combine two different sketches a stepper motor that rotates clockwise and counterclockwise when the ir break beam is broken. I figured first I need to figure out how to use the millis function because once the ir break beam is broken I want the sensor to be unbroken until 60,000 milliseconds. That's where I have a problem I don't know how to execute that , how to virtually turn off the sensor for 60 seconds. It currently works fine with the code given and is plugged into the the 3.3v power source on the arduino. Here's the code I'm using now https://learn.adafruit.com/ir-breakbeam-sensors/arduino

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit Ir break beam sensor help.

Post by adafruit_support_mike »

Take a look at the BlinkWithoutDelay example sketch:

https://www.arduino.cc/en/Tutorial/Buil ... thoutDelay

That shows how to handle event timing with millis().

The basic idea is to store the value millis() will have when it's time for the next event. If you want to wait for a minute, you save the current value of millis() plus 60,000 (now + 60 seconds)

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”