New requests for help, an issue of dc motor limit!

There are three buttons, each button control of independent motor rotation,
I want to achieve is:

Key1: turn left a circle,then turn to the right one and a half circle,and then turn left half a circle.

Every time I go to limit the last lap stop.

Key2:turn right a circle,turn left a circle,Every time I go to limit the last lap stop.

Is not the final lap don't need to stop, even if the trigger limit, don't stop.

key3: turn left a circle,trigger limit stop.

help:I need key1 and key2 the last step is to find the location of the limit switch, touch stop running after the limit switch.

I'm sorry, English Too bad!


Do you have an external pullup on the limit switch? Why not use the internal pullup?

What does the code actually do? How is that different from what you want?

Thanks for properly posting your code. It is rare that new users actually read the guidelines post.

What are you proposing the code must do in order to "find" the location of the limit switch? What motor control devices are you using?
English seems just fine, the lack of details is the problem.

I am using esp12f, I tried, some pin can only be the LOW。

Not sure what that means.

Pin 2 must be pulled high at boot or boot will fail. ESP8266 pin usage.

The ESP8266 supports interrupts in any GPIO, except GPIO16.

Please post a schematic. Hand drawn, photographed and posted is fine. Include all pin names/numbers, components, their part numbers and/or values and power supplies.

Post technical information for relevant components.

Please answer the other questions posted by @Paul_KD7HB.

Thank you for your reply! See note / /after , is what I want.

void left()
{
      //Turn Left a certain distance

      for(int i=0;i<3200;i++){
      digitalWrite(INA1, LOW);
      delayMicroseconds(2000);
      digitalWrite(INA2, HIGH);
      delay(10);
      }
	//Turn right a certain distance
      for(int i=0;i<3500;i++){
      digitalWrite(INA1, HIGH);
      delayMicroseconds(2000);
      digitalWrite(INA2, LOW);
      delay(10);
      }
	//Turn  left again ,now need to detect limit, reaches the limit stop!!
      for(int i=0;i<325;i++){
      digitalWrite(INA1, LOW);
      delayMicroseconds(2000);
      digitalWrite(INA2, HIGH);
      delay(10);
      }
      stoop();
}
void right()
{
			//Turn right
      for(int i=0;i<2700;i++){
      digitalWrite(INA1, HIGH);
      delayMicroseconds(2000);
      digitalWrite(INA2, LOW);
      delay(10);
      }
	//Turn  left again ,now need to detect limit, reaches the limit stop!!
      for(int i=0;i<2845;i++){
      digitalWrite(INA1, LOW);
      delayMicroseconds(2000);
      digitalWrite(INA2, HIGH);
      delay(10);
      }
      stoop();
}

ESP12f Available pin is too little, this does not affect the use,Now the important question is each run last lap cannot detect limit1.
Pics has been updated.

A fundamental truth for programming: if you can't describe what you want to happen and how that be approached, you will NEVER be able to write the code.

I want to achieve is:

Key1: turn left a circle,then turn to the right one and a half circle,and then turn left half a circle.

Every time I go to limit the last lap stop.

Key2:turn right a circle,turn left a circle,Every time I go to limit the last lap stop.

Is not the final lap don't need to stop, even if the trigger limit, don't stop.

key3: turn left a circle,trigger limit stop.

Thank you!
Your key3 seems to be the easiest to program for. What have you tried?

KEY3 I use the interrupt,I know this is not the best way,key1 and key2 during the process of running after the encounter limit1, electricity the opportunity to have a short stop.
For beginners, there is no way that your have any good solution, please advise.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.