# Circuit version of a simple if else program

I have written a simple program that controls two motors (outputs) each with two states ( positive, negative) with an Arduino. The motors states based on the status of four buttons (inputs) (Up, Down, Right, Left). Only one button can be active at a time.

if( up ) {
motor1 = positive ; // +
motor2 = negative ; // -
} else if ( down ) {
motor1 = negative ; // -
motor2 = positive ; // +
} else if ( left ) {
motor1 = negative ; // -
motor2 = negative ; // -
} else if ( right ) {
motor1 = positive ; // +
motor2 = positive ; // +
}

The logic table

| Motor1 | Motor2 |
-------------------------
Right |   +    |   +    |
Left  |   -    |   -    |
Up    |   +    |   -    |
Down  |   -    |   +    |


The program seems simple enough that I think I should be able make a circuit instead of using a micro controller. Using a micro controller seems like a wast for just a simple application.

I have designed the right and left circuit and the up and down circuit separability trying to simplify it. Now I have to merge these two circuits together.

I assume that I will have to use few relays and a "OR transistor" to make the merged circuit. But I am not sure where to start.

Suggestions, comments or diagrams would be greatly appreciated.

Note: These motors are going to be used in a CoreXY table. I created these diagrams with CircuitLab

• I think I got this working for a single motor circuitlab.com/circuit/4p5cgq/screenshot/1024x768 – Steven smethurst May 9 '13 at 7:19
• Beam Robotics shows that complex motorised behaviours can be achieved with a handful of discrete components, without using microcontrollers and software. On the other hand, in terms of circuitry, an 8-pin microcontroller IC isn't notably complicated. – RedGrittyBrick May 9 '13 at 9:07

I'm assuming you are using brushed DC motors

Please correct me if I'm wrong but it sounds like you need to reverse each DC motor independently to give you the basic functionality you need so here is a basic DC motor reverse switch: -

Shown is a DPDT (double pole double throw) switch. It has two independent switches that mechanically activate together; one has three contacts in the left column and the other has three contacts on the right column. The centre pin on each switch is the common pin.

This gets you basic motor reverse functionality and if you had this circuit independently on both motors you could operate the two switches and get left, right, up or down.

However, if you want 4 switches to control all four directions from (say) push-buttons you'd have to convert the DPDT switch on each motor to a DPDT relay and have a bit of steering logic using diodes from the 4 push-buttons activating the coils on the two relays.

Assuming that the default un-powered-relay state produces a LEFT direction, powering relay 1 will cause UP motion. From default, powering relay 2 will cause DOWN and powering both relays will cause RIGHT. You may need an on/off contact/relay/switch too.

Using a micro controller seems like a wast for just a simple application.

My natural inclination is to agree. But there are other points of view. Here's an example of an equally simple application using a relatively simple microcontroller of the same family as that in your Arduino.

From robotroom.com dual fan control