i need help

I want the program to control the engine using infrared sensor so runs the engine if the read sensor is low and when it becomes read sensor high engine sturn off and runs a red light for five minutes and then goes off and actuation green light for five seconds and then goes off and actuation engine again

Post the program that you are having trouble with.

Also draw a simple diagram showing how you have everything connected and post a photo of the drawing.

...R

int snsor1 =13; int sensor2 =12; int redled =10; int greenled=9; int motor = 8; void setup (){ pinMode(sensor1,INPUT); pinMode(sensor2,INPUT); pinMode(sensor1,OUTPUT); pinMode(redled,OUTPUT); pinMode(greenled,OUTPUT); pinMode(motor,OUTPUT); } void loop(){ if (digitalRead(sensor1)==LOW) { digitalWrite(motor,HIGH); digitalWrite(redled,LOW); digitalWrite(greenled,LOW); } else { digitalWrite(motor,LOW); digitalWrite(redled,HIGH); delay(2000); digitalWrite(redled,LOW); digitalWrite(greenled,HIGH); delay(2000); digitalWrite(greenled,LOW); digitalWrite(motor,HIGH);

} if (digitalRead(sensor2)==LOW) { digitalWrite(motor,HIGH); digitalWrite(redled,LOW); digitalWrite(greenled,LOW); } else { digitalWrite(motor,LOW); digitalWrite(redled,HIGH); delay(2000); digitalWrite(redled,LOW); digitalWrite(greenled,HIGH); delay(2000); digitalWrite(greenled,LOW); digitalWrite(motor,HIGH);

}

}

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

For that sort of program you should not use delay() because the Arduino can do nothing else during a delay(). Have a look at how millis() is used to manage timing without blocking in several things at a time

You have not told us what your program actually does compared to what you want it to do.

…R