motor and switch

Hello, all,
I just studied arduino,
I want to control 2 motors with 1 push button, 2 limit switch

under the condition
what if the button is pressed, then motor 1 rotates cw for 2 seconds and motor 2 rotates cw until it touches first limit switch, and after button release motor 1 rotates ccw for 2 second and motor 2 rotates ccw until second limit switch
I am also not very familiar with the schematic

Please help
thanks … :slight_smile: :slight_smile:

What happens if the button is released before the 2 seconds is finished or before motor 2 gets to the limit switch? Same when they are travelling the other way. If the button is pressed again before the motors have finished moving do they immediately reverse direction or finish what they were doing?

Once you have sorted out the detail it shouldn't be too difficult. How far have you got with it? Do you know what motors you are going to use? What you are going to use to drive them? Have you written any code that just recognises when a button is pressed and then when it is released? Do you have any code that drives motors in both directions?

Post details of motors, motor drivers and the code you have so far and I'm sure we can help you get it working.



  • limit switch
  • push buton
  • Motor 12v 3700rpm
  • PSU 12V 2A
  • Arduino UNO/Mega


  • If the button is released before 2 seconds all the motors are turned off, and if the button is pressed the motor continue to the limit switch.

  • If the button is pressed again before the motor moves in the previous direction. (such as the direction of the printhead).