-
-
Notifications
You must be signed in to change notification settings - Fork 1
Usage
SimpleRelay provides high-level abstraction over relay control.
Following functions are available:
-
on()will turn relay on -
off()will turn relay off -
toggle()which will either turn relay on or off, based on previous state -
isRelayOn()which will tell, if a relay is currently on.
Relay object is initialized with a following command:
SimpleRelay relay = SimpleRelay(OUTPUT_PIN);Where OUTPUT_PIN represents a GPIO which, which will control the relay.
Optionally, you can also pass a boolean value isInverted to specify relay characteristic. By default this value is set to false.
A relay is non-inverted, when it will turn on after setting voltage on output pin to HIGH. In contrary, inverted relay will turn on when output voltage is set to LOW.
After a SimpleRelay object is initialized, you can call all of the functions mentioned above.
SimpleRelay also defines a destructor, which will set pin back to high impedance input mode. We're mentioning it here for a full reference. In most cases you'll initialize a relay object and use it in your code until your Arduino board is reset.