rc-gateway/devices/light_sensor/light_sensor.ino
Nicu Hodos 89da9a80e8 re-organize:
- move code for all devices in dedicated folder
- move code for gateway in the root folder
2025-09-20 10:00:42 +02:00

33 lines
464 B
C++

#include "Arduino.h"
#include <TinyPower.h>
#include <Tiny.h>
// Pins
#define SWITCH 0
#define SENDER 2
ContactSensor sensor = ContactSensor(LIGHT_SENSOR, SENDER);
void setup() {
pinMode(SWITCH, INPUT_PULLUP);
sensor.setup();
sensor.sendStateAndVoltage(readState());
TinyPower::setup();
}
void loop() {
TinyPower::sleep();
}
boolean readState() {
return digitalRead(SWITCH);
}
ISR(PCINT0_vect) {
sensor.sendStateAndVoltage(!readState());
}