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
6
currentInputValue
= 0;
7
previousInputValue
= 0;
8
}
9
10
int
Button::isPressed
() {
11
int
state = LOW;
12
currentInputValue
= digitalRead(
pin
);
13
14
if
(
currentInputValue
== HIGH &&
previousInputValue
== LOW)
15
state = HIGH;
16
17
previousInputValue
=
currentInputValue
;
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
src
Button.cpp
Generated on Thu May 13 2021 08:42:38 for HomeWaterLeaksDetection by
1.8.18