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.


  • Mod

    Yes, that is confusing. In 2.0 the examples have been updated to use digitalPinToInterrupt instead, see https://github.com/mysensors/MySensors/commit/3433d2da7885066777bc177f073df87313b9947c


Log in to reply
 

Suggested Topics

  • 1
  • 2
  • 1
  • 2
  • 2
  • 198

1
Online

11.2k
Users

11.1k
Topics

112.5k
Posts