Hello,
I'm just trying to run 5 DC motors through a PIR sensor through my Arduino Genuino Uno.
I can get them to go on when motion is sensed with the following code
// the setup funcion runs once when you press reset or power the board
void setup() { // <<start every new action with opening Brace
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
pinMode(4, OUTPUT); // to the relay, to the motors
pinMode(2, INPUT); // the PIR sensor
// close every action with closing Brace
// the loop function runs over and over again forecer
} void loop() {
if(digitalRead(2)==1){ // if the PIR sensor senses movement (1) (its 0 if not) then the sequence will begin
digitalWrite(4, HIGH); // turn the RELAY on which turns the motors on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH);
}
else{ // else means otherwise
digitalWrite(4, LOW); //the power to the relay/motors will remain off
digitalWrite(LED_BUILTIN, LOW);
}
} // must make sure every opening brace has a closing one
But I want the motors to stay on for 2 minutes, what would i need to add into my code to do this?
Thank you!