Last active
June 2, 2021 18:46
-
-
Save loginov-rocks/0e8f73218224bcbe169dc9a4ae883bb1 to your computer and use it in GitHub Desktop.
DIY Connected Espresso Machine: Relays (Part 2) - Relay.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Relay.h" | |
Relay::Relay(int _pin) | |
{ | |
// Configure pin. | |
pin = _pin; | |
pinMode(pin, OUTPUT); | |
// Off on init. | |
off(); | |
} | |
boolean Relay::getState() | |
{ | |
return digitalRead(pin); | |
} | |
void Relay::on() | |
{ | |
digitalWrite(pin, HIGH); | |
} | |
void Relay::off() | |
{ | |
digitalWrite(pin, LOW); | |
} | |
void Relay::toggle() | |
{ | |
digitalWrite(pin, !getState()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment