This repository has been archived on 2022-11-05. You can view files and clone it, but cannot push or open issues or pull requests.
doorstatus/source/arduino/sensor.cpp
2020-12-28 21:56:24 +01:00

36 lines
1 KiB
C++

/*
Copyright (c):
Philipp Matthias Schäfer (philipp.matthias.schaefer@posteo.de), 2020
This file is part of the KrautStatus' Arduino code.
The Clean CommonMark library is free software: you can redistribute it and/or
modify it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Clean CommonMark library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
for more details.
You should have received a copy of the GNU Affero General Public License along
with the Clean CommonMark library. If not, see <https://www.gnu.org/licenses/>.
*/
#include <Arduino.h>
#include "sensor.h"
#include "config.h"
void sensor_setup() {
pinMode(SENSOR_PIN, INPUT_PULLUP);
}
door_state sensor_get_door_state() {
if (digitalRead(SENSOR_PIN) == HIGH)
return OPEN;
return CLOSED;
}