Using HASwitch object in an array #38
Replies: 2 comments 4 replies
-
Hi @michaelbouma, Yes, that's absolutely possible. I'm using the same approach in one of my projects. Just make sure that each switch is constructed before calling Regarding callback, you can define your logic inside the callback method and assign the same callback to all switches. The caller provides pointer to the HASwitch* as the second argument, so you can define your logic as following: void onSwitchStateChanged(bool state, HASwitch* s) {
if (strcmp(s.uniqueId(), "uniqueId") == 0) { // uniqueId is the name you passed to the constructor
// do something
}
} Please note that |
Beta Was this translation helpful? Give feedback.
-
Hi Michael, I am building a multiple relais project and am very interested in your project. |
Beta Was this translation helpful? Give feedback.
-
Hi,
Im busy with creating some software for the arduino Mega 2560 and discovered this library. I have a lot of IO and wonder if it is possible to use for example HASwitch as an array?
I'm using this
HASwitch *myRelay[NumberOfRelays];
But I have trouble with using the callback. Is is possible to do it ithis way? And how to address the callback?
Beta Was this translation helpful? Give feedback.
All reactions