Error with Timerone & TimerThree library from Paul St

i am trying to use both library in a sketch to send midi clock over usb . using Aduino pro micro 32u4. but after compile
and got error . please look a bit why
as my code

#include <TimerOne.h>
#include <TimerThree.h>
#include <RotaryEncoder.h>
#include "MIDIUSB.h"

const int SW = 4;             
const int CLK = 2;
const int DT = 3;

RotaryEncoder Encoder(DT,CLK);

int encoderValue = 120;
int encoderValueOLD = 120; 

int bpm = 120;        
unsigned long interval = 60000000 / (24 * bpm);

bool startclock = true;

void setup() {
 Serial1.begin(115200);

 pinMode(SW, INPUT);
 attachInterrupt(digitalPinToInterrupt(SW), midiclock_STARTSTOP, RISING);
 Encoder.setPosition(bpm);
   Timer1.attachInterrupt(send_MIDICLOCK);
 Timer3.attachInterrupt(read_ENCODER);
 Timer3.start(interval);
}
   //  --------------------------------------------------------------------------------------------------------------------------------------------------
   void start() {
  midiEventPacket_t start = {0x0F, 0xFA, 0, 0};     
  MidiUSB.sendMIDI(start);
}

void stop() {
  midiEventPacket_t stop = {0x0F, 0xFC, 0, 0};     
  MidiUSB.sendMIDI(stop);
}

void clock() {
  midiEventPacket_t clock = {0x0F, 0xF8, 0, 0};     
  MidiUSB.sendMIDI(clock);
}

void update_TEMPO() {
 interval = 60000000 / (24 * bpm);
 Timer1.start(interval);   // midi clock
 Timer3.start(interval);   // encoder
}

void send_MIDICLOCK() {
 if (startclock) {
   clock();   MidiUSB.flush();
 }
}

void midiclock_STARTSTOP() {
 startclock = !startclock;

 if (startclock) {
   Timer1.start(interval);
   start();  MidiUSB.flush();
 }
 else {
   Timer1.stop();
    stop();  MidiUSB.flush();
 }
}

void read_ENCODER() {
 
 Encoder.tick();
 encoderValue = Encoder.getPosition(); 
 
 if (encoderValue != encoderValueOLD) { 
   encoderValueOLD = encoderValue;

   if (encoderValue > 240) {     encoderValue = 240;   }
   else if (encoderValue < 40) {    encoderValue = 40;  }
   
   bpm = encoderValue;
   Encoder.setPosition(bpm);
   
   SerialUSB.println(bpm);
   update_TEMPO();
 }
}

void loop() {

}

and got error

Arduino: 1.6.8 (Windows 7), Board: "Arduino Leonardo"

C:\Users\acer\Documents\Arduino\Timerone___TimerThree__pjrc_test__with_usb_midi_clock\Timerone___TimerThree__pjrc_test__with_usb_midi_clock.ino: In function 'void setup()':

Timerone___TimerThree__pjrc_test__with_usb_midi_clock:29: error: no matching function for call to 'TimerThree::start(long unsigned int&)'

  Timer3.start(interval);

                       ^

In file included from C:\Users\acer\Documents\Arduino\Timerone___TimerThree__pjrc_test__with_usb_midi_clock\Timerone___TimerThree__pjrc_test__with_usb_midi_clock.ino:3:0:

C:\Users\acer\Documents\Arduino\libraries\TimerThree-master/TimerThree.h:83:10: note: candidate: void TimerThree::start()

     void start() __attribute__((always_inline)) {

          ^~~~~

C:\Users\acer\Documents\Arduino\libraries\TimerThree-master/TimerThree.h:83:10: note:   candidate expects 0 arguments, 1 provided

C:\Users\acer\Documents\Arduino\Timerone___TimerThree__pjrc_test__with_usb_midi_clock\Timerone___TimerThree__pjrc_test__with_usb_midi_clock.ino: In function 'void update_TEMPO()':

Timerone___TimerThree__pjrc_test__with_usb_midi_clock:49: error: no matching function for call to 'TimerOne::start(long unsigned int&)'

  Timer1.start(interval);   // midi clock

                       ^

In file included from C:\Users\acer\Documents\Arduino\Timerone___TimerThree__pjrc_test__with_usb_midi_clock\Timerone___TimerThree__pjrc_test__with_usb_midi_clock.ino:2:0:

C:\Users\acer\Documents\Arduino\libraries\TimerOne-master/TimerOne.h:220:10: note: candidate: void TimerOne::start()

     void start() __attribute__((always_inline)) {

          ^~~~~

C:\Users\acer\Documents\Arduino\libraries\TimerOne-master/TimerOne.h:220:10: note:   candidate expects 0 arguments, 1 provided

Timerone___TimerThree__pjrc_test__with_usb_midi_clock:50: error: no matching function for call to 'TimerThree::start(long unsigned int&)'

  Timer3.start(interval);   // encoder

                       ^

In file included from C:\Users\acer\Documents\Arduino\Timerone___TimerThree__pjrc_test__with_usb_midi_clock\Timerone___TimerThree__pjrc_test__with_usb_midi_clock.ino:3:0:

C:\Users\acer\Documents\Arduino\libraries\TimerThree-master/TimerThree.h:83:10: note: candidate: void TimerThree::start()

     void start() __attribute__((always_inline)) {

          ^~~~~

C:\Users\acer\Documents\Arduino\libraries\TimerThree-master/TimerThree.h:83:10: note:   candidate expects 0 arguments, 1 provided

C:\Users\acer\Documents\Arduino\Timerone___TimerThree__pjrc_test__with_usb_midi_clock\Timerone___TimerThree__pjrc_test__with_usb_midi_clock.ino: In function 'void midiclock_STARTSTOP()':

Timerone___TimerThree__pjrc_test__with_usb_midi_clock:63: error: no matching function for call to 'TimerOne::start(long unsigned int&)'

    Timer1.start(interval);

                         ^

In file included from C:\Users\acer\Documents\Arduino\Timerone___TimerThree__pjrc_test__with_usb_midi_clock\Timerone___TimerThree__pjrc_test__with_usb_midi_clock.ino:2:0:

C:\Users\acer\Documents\Arduino\libraries\TimerOne-master/TimerOne.h:220:10: note: candidate: void TimerOne::start()

     void start() __attribute__((always_inline)) {

          ^~~~~

C:\Users\acer\Documents\Arduino\libraries\TimerOne-master/TimerOne.h:220:10: note:   candidate expects 0 arguments, 1 provided

exit status 1
no matching function for call to 'TimerThree::start(long unsigned int&)'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Hello,

The error is telling you that the start method doesn't take any parameter.

By looking at the library code (and examples), you must set the time with the initialize method ( see here : TimerOne/TimerOne.h at master · PaulStoffregen/TimerOne · GitHub )

32U4 has only Timer1, no Timer3.

Check these libraries, which support 32U4, to see if you can use

  1. TimerInterrupt
  2. TimerInterrupt_Generic

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.