Relay Commands

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 :slight_smile:

Hope this helps someone.

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

relays.h (1.26 KB)


relays.h (1.26 KB)

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.

i no me too

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.

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?