45 #define SKETCH_NAME "Binary Sensor"
46 #define SKETCH_MAJOR_VER "1"
47 #define SKETCH_MINOR_VER "0"
49 #define PRIMARY_CHILD_ID 3
50 #define SECONDARY_CHILD_ID 4
52 #define PRIMARY_BUTTON_PIN 2 // Arduino Digital I/O pin for button/reed switch
53 #define SECONDARY_BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch
55 #if (PRIMARY_BUTTON_PIN < 2 || PRIMARY_BUTTON_PIN > 3)
56 #error PRIMARY_BUTTON_PIN must be either 2 or 3 for interrupts to work
58 #if (SECONDARY_BUTTON_PIN < 2 || SECONDARY_BUTTON_PIN > 3)
59 #error SECONDARY_BUTTON_PIN must be either 2 or 3 for interrupts to work
61 #if (PRIMARY_BUTTON_PIN == SECONDARY_BUTTON_PIN)
62 #error PRIMARY_BUTTON_PIN and BUTTON_PIN2 cannot be the same
64 #if (PRIMARY_CHILD_ID == SECONDARY_CHILD_ID)
65 #error PRIMARY_CHILD_ID and SECONDARY_CHILD_ID cannot be the same
70 MyMessage msg(PRIMARY_CHILD_ID, V_TRIPPED);
71 MyMessage msg2(SECONDARY_CHILD_ID, V_TRIPPED);
76 pinMode(PRIMARY_BUTTON_PIN, INPUT_PULLUP);
77 pinMode(SECONDARY_BUTTON_PIN, INPUT_PULLUP);
83 sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER
"." SKETCH_MINOR_VER);
88 present(PRIMARY_CHILD_ID, S_DOOR);
89 present(SECONDARY_CHILD_ID, S_DOOR);
96 static uint8_t sentValue=2;
97 static uint8_t sentValue2=2;
102 value = digitalRead(PRIMARY_BUTTON_PIN);
104 if (value != sentValue) {
110 value = digitalRead(SECONDARY_BUTTON_PIN);
112 if (value != sentValue2) {
119 sleep(PRIMARY_BUTTON_PIN-2, CHANGE, SECONDARY_BUTTON_PIN-2, CHANGE, 0);