HomeWaterLeaksDetection
Button.cpp
Go to the documentation of this file.
1 #include "Button.h"
2 
3 Button::Button(int pin) {
4  this->pin = pin;
5 
8 }
9 
11  int state = LOW;
12  currentInputValue = digitalRead(pin);
13 
14  if (currentInputValue == HIGH && previousInputValue == LOW)
15  state = HIGH;
16 
18  return state;
19 }
Button::isPressed
int isPressed()
Tests if the button is being pressed.
Definition: Button.cpp:10
Button::Button
Button(int pin)
Constructor of the class.
Definition: Button.cpp:3
Button.h
Button::currentInputValue
int currentInputValue
current state of the input pin
Definition: Button.h:18
Button::pin
int pin
number of the pin the button si connected to
Definition: Button.h:17
Button::previousInputValue
int previousInputValue
previous state of the input pin
Definition: Button.h:19