hai master i have a problem
I want to run a dc motor moves to the right and then after the sensor1 is on motor will stop a few seconds. after the motor moves to the left and when the sensor2 is on motor will stop.
This is the program I have
const int sensortutuppin= 3;//sensor2
const int sensorbukapin= 2;//sensor1
int motor1=5;
int motor2=6;
I gave up on using the debug-by-guesswork approach 35 years ago. I highly recommend debug based on facts. What DID you read from the sensors? Why don't you know?
const int sensortutuppin= 3;
const int sensorbukapin= 2;
int motor1=5;
int motor2=6;
int sensorbuka;
int sensortutup;
void setup()
{
pinMode(sensortutuppin, INPUT);
pinMode(sensorbukapin, INPUT);
pinMode(motor1, OUTPUT);
pinMode(motor2, OUTPUT);
sorry sir, my code can not work the way I expected. I expect is that the motor can move to the right and then stop and then move and then stop, but in fact with the code only complains motors move to the right and then stop. Do not move to the left. Thank you
There are conditions under which you think the motor should move to the left (whatever that means for a rotating device). Are those conditions ACTUALLY ever present? Why are you guessing? Add some Serial.print() statements and KNOW.