Also still need to make sure that these 2 transistors are not going to both be powered tryingto turn the motor in opposite directions of each other and causing a short or other problems.

You haven't posted your schematics and I don't know how you can wire two relays in such a way that the motor could be trying to be driven in two directions at once. It sounds like a poor circuit if this is the case. Using two relays you implement a reversal of the motor as shown in this page:-http://www.thebox.myzen.co.uk/Workshop/Motors_1.htmlThere is no way that can be commanded to go wrong.

Quote

But where to insert the IF statement?

Don't tempt me!Read what I said:-In place of the switch statement just use compound ifs.So you replace the switch statement with a string of compound ifs

Quote

I like the idea ofQuoteif(letter == 'F' || pushButton == true) { // do your stuffalthough I am sure the coding of this is not quits as simple. It would be nice to know theSyntax.

Yes it is that is the syntax where letter is the variable with the command letter in and pushButton is the Boolean variable with the state of the button in.

Read what I said:-In place of the switch statement just use compound ifs.So you replace the switch statement with a string of compound ifs

I read what you said, what I am wondering is how will the device know what the different parts are;

if(letter == 'F' || pushButton == true) { // do your stuff

I got the "letter == 'F'" as in You press "F", but how does it know what "letter" is or "pushButton == true" how does it know what these things refer to? Where is that written?

This is why I was asking for an example and showed my example over again.

The relays I am working with are already built into the motor, I have never actually tried turning them both on at the same time. Maybe I will disassemble one and see how they are actually wired. I was working on the side of caution as to not wanting bothof them enabled at the same time. It am still testing here and seeing what is available out there. We will call this - still gathering ideas =)

I got the "letter == 'F'" as in You press "F", but how does it know what "letter" is or "pushButton == true" how does itknow what these things refer to? Where is that written?

Well in your code how does it know what inByte is?

Come on put in a bit of effort.

Hint:-1) in my code letter is the same as inByte in your code.2) how do you think you will get the state of a push button's state into a variable? Could it be something to do with reading the digital pin it is attached to?

jwatte

If he is then there is no need at all to worry about the order the relays are energised as taking a motor to the same potential will only help stop the motor before reversing the rotation. In fact it is probable a good idea to have a brief time in this state to prevent damage to the motor.

With normal two-pole two-relay wiring, energizing both relays at the same time will actually create a short from power to ground. You *really* don't want that :-)

jwatte

Note that the design above shorts the motor when it's not running, which will make it brake (because the magnets will work as a generator with infinite load).

The design I was thinking about de-couples the motor when not running, so it will free-wheel -- but has the notable draw-back that it shorts the motor voltage if you pull both relay 1 and relay 2 at the same time.

Well OK I will give you that.However, you are using a more expensive relay (two pole change over in place of one pole change over) and your only "win" is free wheel breaking, which I think is the last thing you need if you are trying to control a robot.So while that would work I would think only an idiot would use that wiring.