Skip to content

Instantly share code, notes, and snippets.

@loginov-rocks
Last active June 2, 2021 18:46
Show Gist options
  • Save loginov-rocks/0e8f73218224bcbe169dc9a4ae883bb1 to your computer and use it in GitHub Desktop.
Save loginov-rocks/0e8f73218224bcbe169dc9a4ae883bb1 to your computer and use it in GitHub Desktop.
DIY Connected Espresso Machine: Relays (Part 2) - Relay.cpp
#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