I would like to have my spark monitor a magnetic button (Switch1) and a push button (Switch2).
I am currently doing this in my loop() reading eachtime the state of the two with digitalRead and if the status changes, different functions are called consequently. (status does not change frequently)
What is the advantage of using instead the interrupts http://docs.spark.io/firmware/#other-functions-interrupts such as:
attachInterrupt(D0, doOpenFunc, RISING);
attachInterrupt(D0, doCloseFunc, FALLING);
attachInterrupt(D1, doOn, RISING);
attachInterrupt(D1, doOff, FALLING);
making my “do” functions update some variables to be analyzed anyhow in the loop()… where I can have eventual delays…
is there a smarter way of using this or making this monitoring system?