I'm having trouble adding attachInterrupt in a library that I am creating. I researched a lot, and I noticed that this is a common mistake, but do not quite understand the answers I found.
The error in question is this:
sketch_nov04a.ino: In function 'void setup()':
sketch_nov04a:10: error: argument of type 'void (Teste::)()' does not match 'void (*)()'
My library is as follows:
Teste.h
#ifndef TESTE_H
#define TESTE_H
#include <Arduino.h>
class Teste
{
public:
volatile long lastWindIRQ;
volatile byte windClicks;
void wspeedIRQ();
};
#endif
Teste.cpp
#include "Teste.h"
void Teste::wspeedIRQ()
{
if (millis() - this.lastWindIRQ > 10)
{
this.lastWindIRQ = millis();
this.windClicks++;
}
}
my implementation
#include <Teste.h>
Teste teste;
void setup()
{
Serial.begin(9600);
pinMode(2, INPUT);
digitalWrite(2, HIGH);
attachInterrupt(0, teste.wspeedIRQ, FALLING);
}
void loop()
{
Serial.println(teste.windClicks);
delay(3000);
}
EDIT: Updated the error and corrected the problem cited by Ignacio