Skip to main content
elaborated
Source Link

As for the arduino you can create a variable, say 'directionstatus' (yes long name abbreviate as required)

This is not code but rather the logic of operation - Create an IF statement in the loop to do the following:

If switch pressed
    If directionstatus = 1
    direction status =0
    ***Insert code to initiate one direction here***
    Else 
    directionstatus = 1
    ***Insert code to initiate other direction here*** 
    EndIf
EndIf

Then you can use either relays or mosfets or otherwise to operate the motor, and initiate the drive. If you want further elaboration please say.

It is possible to do without an arduino but you seem to have one already there and useful and potentially ready to go.

Added benefit of using a uC is if you know the speed and implement some timings etc you could control travel, and if you move to stepper motors later on (not sure if your application requires) you can have very precise control quite easily - but for now I would imagine an If in void_loop that operates when button is pressed would suffice.

... P.S.

Just thought - please have a look at this as this might be upset your code later on as each time the switch is initiated it may bounce, plus you might find it triggers when it actuates and triggers when you leave (in which case update code to ignore every second instruction) https://www.arduino.cc/en/Tutorial/Debounce

As for the arduino you can create a variable, say 'directionstatus' (yes long name abbreviate as required)

This is not code but rather the logic of operation - Create an IF statement in the loop to do the following:

If switch pressed
    If directionstatus = 1
    direction status =0
    ***Insert code to initiate one direction here***
    Else 
    directionstatus = 1
    ***Insert code to initiate other direction here*** 
    EndIf
EndIf

Then you can use either relays or mosfets or otherwise to operate the motor, and initiate the drive. If you want further elaboration please say.

It is possible to do without an arduino but you seem to have one already there and useful.

As for the arduino you can create a variable, say 'directionstatus' (yes long name abbreviate as required)

This is not code but rather the logic of operation - Create an IF statement in the loop to do the following:

If switch pressed
    If directionstatus = 1
    direction status =0
    ***Insert code to initiate one direction here***
    Else 
    directionstatus = 1
    ***Insert code to initiate other direction here*** 
    EndIf
EndIf

Then you can use either relays or mosfets or otherwise to operate the motor, and initiate the drive. If you want further elaboration please say.

It is possible to do without an arduino but you seem to have one already there and useful and potentially ready to go.

Added benefit of using a uC is if you know the speed and implement some timings etc you could control travel, and if you move to stepper motors later on (not sure if your application requires) you can have very precise control quite easily - but for now I would imagine an If in void_loop that operates when button is pressed would suffice.

... P.S.

Just thought - please have a look at this as this might be upset your code later on as each time the switch is initiated it may bounce, plus you might find it triggers when it actuates and triggers when you leave (in which case update code to ignore every second instruction) https://www.arduino.cc/en/Tutorial/Debounce

Source Link

As for the arduino you can create a variable, say 'directionstatus' (yes long name abbreviate as required)

This is not code but rather the logic of operation - Create an IF statement in the loop to do the following:

If switch pressed
    If directionstatus = 1
    direction status =0
    ***Insert code to initiate one direction here***
    Else 
    directionstatus = 1
    ***Insert code to initiate other direction here*** 
    EndIf
EndIf

Then you can use either relays or mosfets or otherwise to operate the motor, and initiate the drive. If you want further elaboration please say.

It is possible to do without an arduino but you seem to have one already there and useful.