- move code for all devices in dedicated folder - move code for gateway in the root folder
33 lines
464 B
C++
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());
|
|
}
|