I am getting an error message when I try to attach an interrupt to D3. I can call scale.tare otherwise but it wont let me here. Any ideas why?
If the rest of the code will help let me know and I will post it.
Thanks!
I am getting an error message when I try to attach an interrupt to D3. I can call scale.tare otherwise but it wont let me here. Any ideas why?
If the rest of the code will help let me know and I will post it.
Thanks!
It looks like you are trying to attach a class method to an interrupt and that is different from a function. Can you try wrapping scale.tare() up in a function and attach that instead?
you are right I think… that is a class method. I try and change it over to a function and see if that works! Thanks
You can use object methods, but you’ll need to use this overload of attachInterrupt()
https://docs.particle.io/reference/firmware/photon/#attachinterrupt-
class Robot {
public:
Robot() {
pinMode(D2, INPUT_PULLUP);
attachInterrupt(D2, &Robot::handler, this, CHANGE);
}
void handler() {
// do something on interrupt
}
};
Robot myRobot;
This takes the function pointer of the class method and the instance pointer of the respective object.