Log in

View Full Version : Relay Commands


Matt Krass
17-02-2006, 20:49
I had some free time tonight and I noticed some people are having problems with relays, usually remembering to set both the corresponding FWD and REV values, so I wrote up a quick header file with commands to set relays forward, reverse or off simply by typing RELAY#_FWD or _REV or _OFF

Examples, setting Relay 1 forward

RELAY1_FWD;


Relay 1 reverse

RELAY1_REV;


Relay 1 off

RELAY1_OFF;


The semicolon is important, I designed it that way to be syntax compatible with C, some IDEs don't like commands without semicolons :)

Hope this helps someone.

Simply drop in your project and add #include "relays.h" where ever you use it.

X-Istence
17-02-2006, 22:08
I forgot to set the reverse to 0 when I first tried. Once you know how it works, getting it to work is not a problem.

Matt Krass
18-02-2006, 01:01
I forgot to set the reverse to 0 when I first tried. Once you know how it works, getting it to work is not a problem.

I wrote it to make programming a little simpler, nobody is saying you have to use it or not use it, it's out there if you wish to.

lil_longo
18-02-2006, 15:04
I forgot to set the reverse to 0 when I first tried. Once you know how it works, getting it to work is not a problem.

i no me too

Anime-niac_2.9
18-02-2006, 18:00
the RELAY_OFF shouldn't be needed, but then again if you're a noob and the easy C key you were given doesn't work then this will work since it's in a header file.

Mike
18-02-2006, 18:32
Good job. I wouldn't limit the usage of this to "C noobs" either. Everyone can benefit from the readability change from

relay1_fwd = 0;
relay1_rev = 1;

to

RELAY1_OFF;

DanDon
18-02-2006, 23:03
Good job. I wouldn't limit the usage of this to "C noobs" either. Everyone can benefit from the readability change from

relay1_fwd = 0;
relay1_rev = 1;

to

RELAY1_OFF;


Hey Mike, wouldn't that be RELAY1_REV?
And of would be relay1_fwd=relay1_rev=0?