38 lines
677 B
C++
38 lines
677 B
C++
#ifndef RELAY_CONTROLLER_H
|
|
#define RELAY_CONTROLLER_H
|
|
|
|
#include <Arduino.h>
|
|
|
|
class RelayController {
|
|
private:
|
|
const int _relayPin;
|
|
bool _isConnected;
|
|
|
|
public:
|
|
RelayController(int relayPin) :
|
|
_relayPin(relayPin),
|
|
_isConnected(false) {
|
|
pinMode(_relayPin, OUTPUT);
|
|
disconnect();
|
|
}
|
|
|
|
void connect() {
|
|
digitalWrite(_relayPin, LOW);
|
|
_isConnected = true;
|
|
}
|
|
|
|
void disconnect() {
|
|
digitalWrite(_relayPin, HIGH);
|
|
_isConnected = false;
|
|
}
|
|
|
|
bool isConnected() const {
|
|
return _isConnected;
|
|
}
|
|
|
|
int getPin() const {
|
|
return _relayPin;
|
|
}
|
|
};
|
|
|
|
#endif |