Question: Help programming a servo motor with arduino to open and then close when a motion sensor is set off and then stay off for a

Help programming a servo motor with arduino to open and then close when a motion sensor is set off and then stay off for a specified amount of time even if the motion sensor is set off again.

Pin 13 is an LED that tells me when the motion sensor is set off. The signal pin of the PIR motion sensor is connected to pin 3. The servo is connected to pin 9.

Currently, if the motion sensor is HIGH, the servo will turn 60 degrees and then turn back to 0 degrees. Else the motion sensor is LOW it will stay at 0 degrees.

My question is: What code can I add that will keep the motor from turning on again until a specified amount of time has passed (say 10 minutes) and yes I do have the clock module Gikfun DS1307 AT24C32 for arduino.

Help programming a servo motor with arduino to open and then close

Picture of my current set up (clock module is not in the picture but is ready to go)

This is my current code:

#include

Servo myservo;

int motion;

void setup(){ pinMode(13, OUTPUT); pinMode(3, INPUT); myservo.attach(9); } void loop(){

motion = digitalRead(3);

if (motion == HIGH) { digitalWrite(13, HIGH); myservo.write(60); delay(50); myservo.write(0);

} else { digitalWrite(13, LOW); myservo.write(0); delay(15); } }

C1 clock module not pictured

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!