title: interrupts on creating arduino library
body: <p>I'm creating a library for an energy counter. I want to count the pulses the energy counter produce and convert it to energy, through the arduino. To catch any pulse I want to use the arduino interrupts. I want it to be easy to use:</p>
  
  <pre><code>#include &lt;EnergyCounter.h&gt;
  
  #define counterPin 2; // interrupt code 0 in Uno
  EnergyCounter counter;
  
  void setup(){
      counter.begin(counterPin);
  }
  ...
  </code></pre>
  
  <p>Now, inside the <em>begin</em> method I want to attach an interrupt to the <em>counterPin</em>:</p>
  
  <pre><code>void EnergyCounter::begin(byte pin){
      pinMode(pin, INPUT);
      attachInterrupt(0, countPulse, RISING);
  }
  
  void EnergyCounter::countPulse(){
      display += increment_per_pulse;
  }
  </code></pre>
  
  <p>When I try it I get the following error:</p>
  
  <pre><code>error: cannot convert 'EnergyCounter::countPulse' from type 'void (EnergyCounter::)()' to type 'void (*)()'
   attachInterrupt(0, countPulse, RISING);
                                        ^
  Erro ao compilar.
  </code></pre>
  
  <p>Does this mean that I cannot use a method as Interrupt Service Routine (ISR)?
  How can I solve the problem and yet have an easy to use interface to the library?</p>