This class controls an array of relays in a simple way.
More...
#include <RelaysDriverBasic.h>
|
template<typename T , size_t n> |
| RelaysDriverBasic (bool _active, const T(&pins)[n]) |
| constructor. More...
|
|
void | begin () |
| this function should be called on startup. It sets up pinmodes. More...
|
|
void | set (uint16_t bits) |
| activate relays corresponding to a bit that's 1. More...
|
|
virtual void | set (uint16_t bits)=0 |
| activate relays corresponding to a bit that's 1. More...
|
|
virtual void | begin ()=0 |
| this function should be called on startup. It sets up pinmodes. More...
|
|
|
void | write (byte relay, bool setState) |
| set a specific relay to a state, just to keep the code that actually drives a relay separate More...
|
|
template<uint8_t N>
class RelaysDriverBasic< N >
This class controls an array of relays in a simple way.
- Note
- This class could also work with transistors or MOSFETs, which are better than mechanical relays in terms of switching time and lifetime. It uses GPIO pins, and has no compensation for switching time.
- Parameters
-
N | how many relays need to be controlled. N must be <=16 (because set() uses a 16 bit variable). |
◆ RelaysDriverBasic()
template<uint8_t N>
template<typename T , size_t n>
constructor.
- Parameters
-
_active | do the switches activate on a HIGH or LOW output? |
pins | {list, of, pins} |
◆ begin()
this function should be called on startup. It sets up pinmodes.
Implements RelaysDriver.
◆ set()
activate relays corresponding to a bit that's 1.
- Note
- 1 is the LSB, e.g. 001 turns on the first relay.
- Parameters
-
bits | Think of this number as an array of bits. Bits that there is no relay for are ignored. |
Implements RelaysDriver.
◆ write()
set a specific relay to a state, just to keep the code that actually drives a relay separate
- Parameters
-
relay | [0,N) the relay to write to |
setState | true=active false=inactive |
◆ active
◆ pin
The documentation for this class was generated from the following file: