I am a Beginner in Arduino Programming. I am working on a project where I control A DC motor with IR sensor and arduino.
Until here it is fine. But I want the Motor to stop after one second even though the IR sensor detects the Obstacle
Here's My Program
Pin 2- IR Sensor Pin 4,5,6- Motor
enter code here
//Included Libraries
#include <motor.h>
//MACROS are defined here
Motor Motor1(4, 5, 6);
void setup() {
//put your setup code here, to run once:
pinMode(2, INPUT);
}
void loop() {
//put your main code here, to run repeatedly:
if(digitalRead(2)) {
Motor1.moveMotor(2.55*0);
}
else {
Motor1.moveMotor(2.55*100);
}
}
Can anyone help out in this Program. I Just want the Motor to stop after one second. Thank you in advance!
{}
button to format it. – Duncan C Jun 5 '20 at 19:52Motor1.moveMotor(2.55*100); delay(1000); Motor1.moveMotor(0);
work for you? – Thomas Weller Jun 5 '20 at 20:42StateChangeDetection
– jsotola Jun 6 '20 at 18:52