Hello,
I hope you can help me… I am trying to write my own library for some functions. In all there are 4 or 5 libraries… Now I have the following problem:
sha_switch.cpp:37:47: error: no matching function for call to 'attachInterrupt(int&, <unresolved overloaded function type>, InterruptMode)'
attachInterrupt(_inputPin, lever, FALLING);
^
Here is my sha_switch.h:
#include "application.h"
#ifndef sha_switch_h
#define sha_switch_h
class SHASwitch {
public:
SHASwitch();
void setup(int inputPin, int pwmPin, int relais1, int relais2);
bool turnOff();
bool turnOn();
bool lever();
private:
int _inputPin;
int _pwmPin;
int _relais1;
int _relais2;
int _state;
};
#endif
Here is my sha_switch.cpp:
#include "sha_switch.h"
SHASwitch::SHASwitch() {
}
void SHASwitch::setup(int inputPin, int pwmPin, int relais1, int relais2) {
/* ----- Setting Up Pins for Lever ----- */
pinMode(inputPin,INPUT);
pinMode(pwmPin, OUTPUT);
/* ----- Setting Up Pin for Relais ----- */
pinMode(relais1,OUTPUT);
pinMode(relais2, OUTPUT);
/* ----- Save Pins into private variables ----- */
_inputPin = inputPin;
_pwmPin = pwmPin;
_relais1 = relais1;
_relais2 = relais2;
/* Setup Interrupt */
attachInterrupt(_inputPin, lever, FALLING);
}
bool SHASwitch::turnOff() {
digitalWrite(_relais1, HIGH);
digitalWrite(_relais2, LOW);
delay(100);
digitalWrite(_relais1, LOW);
_state = 0;
return true;
}
bool SHASwitch::turnOn() {
digitalWrite(_relais2, HIGH);
digitalWrite(_relais1, LOW);
delay(100);
digitalWrite(_relais2, LOW);
_state = 1;
return true;
}
bool SHASwitch::lever() {
switch(_state) {
case 1:
turnOff();
case 0:
turnOn();
}
return true;
}
I think you would find the error quickly… I also take a look in some communities and also locked into other libraries how they have done this… but I have no more ideas…
Best greeting,
Stefan