3

I'm trying to use the TTS library for Arduino on an Arduino Micro board, which is based on the Leonardo. When I try to compile my sketch I get some errors;

/libraries/TTS/TTS.cpp: In function 'void soundOff()':
/libraries/TTS/TTS.cpp:355: error: 'TCCR2A' was not declared in this scope
/libraries/TTS/TTS.cpp:355: error: 'COM2B1' was not declared in this scope
/libraries/TTS/TTS.cpp: In function 'void soundOn()':
/libraries/TTS/TTS.cpp:382: error: 'TCCR2A' was not declared in this scope
/libraries/TTS/TTS.cpp:382: error: 'COM2B1' was not declared in this scope
/libraries/TTS/TTS.cpp:382: error: 'WGM20' was not declared in this scope
/libraries/TTS/TTS.cpp:383: error: 'TCCR2B' was not declared in this scope
/libraries/TTS/TTS.cpp:383: error: 'CS20' was not declared in this scope
/libraries/TTS/TTS.cpp:383: error: 'WGM22' was not declared in this scope
/libraries/TTS/TTS.cpp:384: error: 'OCR2B' was not declared in this scope
/libraries/TTS/TTS.cpp:385: error: 'TCNT2' was not declared in this scope
/libraries/TTS/TTS.cpp: In function 'void sound(byte)':
/libraries/TTS/TTS.cpp:424: error: 'OCR2B' was not declared in this scope
/libraries/TTS/TTS.cpp:425: error: 'TCNT2' was not declared in this scope

Googling revealed that the Leonardo uses different timers. And other things I don't understand! But I couldn't piece together an answer beyond that.

What are the correct constants to use for Leonardo boards, and is there a way I can update the library to work across both?

  • The hilarious part is that the Arduino libraries provide MCU-independent ways to do all that and this code completely ignores all of them. – Ignacio Vazquez-Abrams Apr 11 '15 at 19:56
  • @IgnacioVazquez-Abrams Great news! Do you have a link on how to use that feature of the library, or an example please? – NoChecksum Apr 11 '15 at 20:01
  • 2
    This "library" is written specifically for the ATMega328 (not the ATmega32u4 inside the Leonardo). You should be able to port it. Not hard, but not also a task for a beginner. – Gerben Apr 11 '15 at 20:14
  • Eh. I just noticed that it uses parameters not controlled by the basic libraries. You'd need to find a more fully-featured PWM library for it. But barring that conditional compilation would be the way to go. – Ignacio Vazquez-Abrams Apr 11 '15 at 20:25
  • Do you have to use a Micro? Your code will probably work on a Uno (or some other ATmega328 based board). To check, select Uno under the Tools->Board menu and then try to compile it. – Greenonline Aug 4 '15 at 21:09
0

Apparently the library in the OP's link has been updated to support the Leonardo, so this problem should now be solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.