Quick question on BinarySwitchSleepSensor example
-
I only have one sensor attached to my node, so I changed the BinarySwitchSleepSensor example to only recognize one. I changed PRIMARY_BUTTON_PIN to BUTTON_PIN, changed PRIMARY_CHILD_ID to CHILD_ID, erased SECONDARY_BUTTON_PIN and SECONDARY_CHILD_ID, and then deleted the portions referring to the secondaries. But I'm stumped on the last line in the sketch:
sleep(PRIMARY_BUTTON_PIN-2, CHANGE, SECONDARY_BUTTON_PIN-2, CHANGE, 0);
Presumably, I can just delete ", SECONDARY_BUTTON_PIN-2, CHANGE" and switch the PRIMARY_BUTTON_PIN-2 to BUTTON_PIN-2 and it will work, but I'm wondering what the "-2" at the end of BUTTON_PIN is. Does the -2 do something on the function end that I'm not seeing. I want to make sure that isn't a number I need to fiddle with (I'm guessing not as both PRIMARY and SECONDARY are -2). Thanks.
Oh, and the Library API doesn't mention what that -2 does, I already checked.
Edit -- wait a minute, is that a minus?
-
Nevermind, I think I figured it out. In the Library API it says:
On Nano/Pro Mini: 0=Pin2, 1=Pin3
Which means that minus 2 would turn pin 2 to 0 and pin3 to 1 -- I feel like an idiot. What's that dash do? Lol. It's a minus and it uses the pin number to get the proper interrupt #.
Leaving this here in case anyone in the future has this issue.
-
Yes, that is confusing. In 2.0 the examples have been updated to use digitalPinToInterrupt instead, see https://github.com/mysensors/MySensors/commit/3433d2da7885066777bc177f073df87313b9947c
Suggested Topics
-
Arduino Celebrates 10 years (Malmö/Sweden)
Announcements • 29 Mar 2014, 17:08 • hek 29 Mar 2014, 17:08 -
Counting Incoming and Outgoing Messages from a Gateway
Development • 10 Dec 2024, 21:57 • Trand 14 Dec 2024, 20:23 -
Adding Listen only device to my system.
Development • 26 Feb 2025, 00:39 • dpcons 26 Feb 2025, 06:26 -
PJON and Minicore not working
Development • 21 Mar 2025, 19:51 • Trand 21 Mar 2025, 19:51 -
Gateway without a radio
Development • 12 Jan 2025, 23:19 • OldSurferDude 14 Jan 2025, 22:07 -
Radio waking up for no reason.
Development • 4 Jul 2020, 21:09 • Sasquatch 15 Jan 2025, 08:33