Relay code

How do you program a spike relay? For example what code would i use to get a spike relay to go forward, then stop?

Do you want it to go forward for X seconds, or when you press a stop button?

To create it, you’d first make the object in Java.

Relay myRelay = new Relay(int moduleNumber, int channel);

Now that we created the Relay object, we can tell it what to do. If you want it to go forward, you could do something like this:


myRelay.set(kForward);

To turn it off, you would instead use:

myRelay.set(kOff);

Where and how you use those pieces of code is dependent on when or how you want the values to change. Will it be time based? Do you want a button to turn it off, or maybe a sensor instead?