Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // +-\/-+
- // 1|o |8 VCC/CE RED/ORANGE
- // YELLOW CSN 2| |7 SCK GREEN
- // - SENSOR 3| |6 MOSI BLUE
- // BLACK GND 4| |5 MISO VIOLET
- // +----+
- #include <MySensor.h>
- #include <Bounce2.h>
- #define NODE_ID 1
- #define CHILD_ID 1
- MySensor gw;
- Bounce debouncer = Bounce();
- int oldValue = -1;
- MyMessage msg(NODE_ID, V_TRIPPED);
- void setup()
- {
- pinMode(4, INPUT);
- digitalWrite(4, HIGH);
- debouncer.attach(4);
- debouncer.interval(5);
- gw.begin(NULL, NODE_ID, false, 0);
- gw.present(CHILD_ID, S_DOOR);
- }
- void loop()
- {
- debouncer.update();
- int value = debouncer.read();
- if (value != oldValue) {
- gw.send(msg.set(value==HIGH ? 1 : 0));
- oldValue = value;
- }
- gw.sleep(PCINT4,CHANGE, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement