Compiling Teensy code in Arduino IDE 2.0.3

tcross99

Member
Newbie here...

I'm working on an LED Metronome project that was developed on the Teensy 3.2. I'm using an espressif esp-32 dev board on the Arduino IDE. Developer had said that the code should compile OK but it is throwing a lot of errors such as:

C:\Users\Tom\Documents\Arduino\LEDmetronome\MetroDrumv1.19\MetroDrumv1.19.ino: In function 'void eventMetro()':
C:\Users\Tom\Documents\Arduino\LEDmetronome\MetroDrumv1.19\MetroDrumv1.19.ino:135:47: error: too many arguments to function 'void analogWriteFrequency(uint32_t)'
analogWriteFrequency ( BEEPER, FREQUENCY2 );

Q: Would loading the Teensyduino app help solve this issue? Or just adding Paul's Teensy board package to my Arduino IDE? These are errors that show without verbose output so I know there pretty major. This is just a high level question to find out if I'm even in the right ballpark.

I have purchased a Teensy 4.0 to make this work with mods to the sketch for different pins but until my Teensy arrives I thought I would see if my problem can be solved with software.

Thanks, Tom
 
I believe that the teensy libraries (to include the audio library) only work with the teensy hardware. If you load up the teensy board definition into the IDE and install the libraries you should be able to develop/compile the code just fine. You will just not be able to load it onto a non-teensy board and have it execute. So you don't need a teensy board attached to your computer to compile, just to load/use. Hope this helps.
 
Sorry have no idea if the sketch can or can not work on ESP32.... We don't see the actual sketch.

But the error:
Code:
C:\Users\Tom\Documents\Arduino\LEDmetronome\MetroD rumv1.19\MetroDrumv1.19.ino: In function 'void eventMetro()':
C:\Users\Tom\Documents\Arduino\LEDmetronome\MetroD rumv1.19\MetroDrumv1.19.ino:135:47: error: too many arguments to function 'void analogWriteFrequency(uint32_t)'
analogWriteFrequency ( BEEPER, FREQUENCY2 );
Is probably because on the Teensy the analogWriteFrequency has two arguments, pin and frequency

Code:
void analogWriteFrequency(uint8_t pin, float frequency);
. And the ESP32 looks like it only has one:
Code:
analogWriteFrequency(uint32_t freq)
Where the teensy can set the PWM frequency per pin (actually in some cases a group of up to 3 pins). Not sure what the ESP32 does.
 
Thanks for the informed responses. I'll wait until I get my Teensy...

But...if I wanted to learn more about coding the hardware, can you please point me to a tutorial? In the meantime, I'll search through these forums to learn what I can.

Thanks again...
 
Well a LOT of information is contained at this page and its sub pages: https://www.pjrc.com/teensy/

There are tutorials for the audio library (some) but most of the information is documentation about the hardware and the teensy Arduino libraries, all available in those pages at the link. There are a lot of examples as well.
 
To make a short story long...I suffered through an esp32 that turned out to be a nodemcu. Thanks, I'll stick to my Teensy 4.0 from Sherwood...:)

So I'm starting at the very beginning and understanding more and more. But, here's my first challenge. Loading up the code from https://www.pjrc.com/teensy/td_digital.html I get compilation errors stating that "PIN_D6 (and PIN_D7) was not declared in this scope. Exit status 1

Q: Where can I learn what code mod I need to make to correct this error?

Thanks, Tom

Here's the code:

Code:
void setup()
{
  pinMode(PIN_D6, OUTPUT);       // LED
  pinMode(PIN_D7, INPUT_PULLUP); // Pushbutton
}

void loop()
{
  if (digitalRead(PIN_D7)) {
    // D7 pin is high due to pullup resistor
    digitalWrite(PIN_D6, LOW);   // LED on
    delay(400);                  // Slow blink
    digitalWrite(PIN_D6, HIGH);  // LED off
    delay(400);
  } else {
    // D7 pin is low due to pushbutton pressed
    digitalWrite(PIN_D6, LOW);   // LED on
    delay(80);                   // Fast blink
    digitalWrite(PIN_D6, HIGH);  // LED off
    delay(80);
  }
}

Just did a complete rip out of Arduino 2.0.3 forcing a clean reinstall, fresh install of Teensyduino and reset my Teensy (so glad to see the slow blinking LED)

Still getting this:

C:\Users\Tom\AppData\Local\Temp\.arduinoIDE-unsaved2023117-12144-lkq1w1.5tilg\sketch_feb17a\sketch_feb17a.ino: In function 'void setup()':
C:\Users\Tom\AppData\Local\Temp\.arduinoIDE-unsaved2023117-12144-lkq1w1.5tilg\sketch_feb17a\sketch_feb17a.ino:3:11: error: 'PIN_D6' was not declared in this scope
pinMode(PIN_D6, OUTPUT); // LED
^
C:\Users\Tom\AppData\Local\Temp\.arduinoIDE-unsaved2023117-12144-lkq1w1.5tilg\sketch_feb17a\sketch_feb17a.ino:4:11: error: 'PIN_D7' was not declared in this scope
pinMode(PIN_D7, INPUT_PULLUP); // Pushbutton
^
C:\Users\Tom\AppData\Local\Temp\.arduinoIDE-unsaved2023117-12144-lkq1w1.5tilg\sketch_feb17a\sketch_feb17a.ino: In function 'void loop()':
C:\Users\Tom\AppData\Local\Temp\.arduinoIDE-unsaved2023117-12144-lkq1w1.5tilg\sketch_feb17a\sketch_feb17a.ino:9:19: error: 'PIN_D7' was not declared in this scope
if (digitalRead(PIN_D7)) {
^
C:\Users\Tom\AppData\Local\Temp\.arduinoIDE-unsaved2023117-12144-lkq1w1.5tilg\sketch_feb17a\sketch_feb17a.ino:11:18: error: 'PIN_D6' was not declared in this scope
digitalWrite(PIN_D6, LOW); // LED on
^
C:\Users\Tom\AppData\Local\Temp\.arduinoIDE-unsaved2023117-12144-lkq1w1.5tilg\sketch_feb17a\sketch_feb17a.ino:17:18: error: 'PIN_D6' was not declared in this scope
digitalWrite(PIN_D6, LOW); // LED on
^

exit status 1

Compilation error: 'PIN_D6' was not declared in this scope

Where do I learn what I need to do to fix this?

Thanks, Tom
 
Last edited by a moderator:
To make a short story long...I suffered through an esp32 that turned out to be a nodemcu. Thanks, I'll stick to my Teensy 4.0 from Sherwood...:)
...

That linked page is specific to the PRE-ARM Teensy family using AVR - and that sample is from back then too. There is a table on the right edge showing the 'Teensy' it applies to.

For the ARM Teensy the reference card shows EDGE pins 0 to 23 or 39 or 41 depending on the actual unit. Teensy 4.0 edge pins are numbered 0-23 and using that number alone will work to indicate the desired pin.

Looking at the card - deciding what pin fits the build at hand then: pinMode(13, OUTPUT); and digitalWrite(13, LOW); // LED on

Where pin 13 has the LED_BUILTIN {also a define that can be used where LED_BUILTIN on T_4.0 resolves to 13}

Also the toolbar '#' hashtag can be used to encapsulate "CODE" when posted to preserve indentation for readability.

<edit> Made an issue for this page: PaulStoffregen/Website_Updates/issues/38
 
Thanks for the clear response, defragster. After posting I realized that the problem was probably related to my version of Teensy as I had seen that table and should have paid attention to it.

Tom
 
I wanted to circle back to let you responders know that I succeeded in getting my LED metronome working. Thanks to all for the kind assistance.

[video]https://drive.google.com/file/d/1bKBBWN2zdtokY-YksoHPU4MMlhyEr7PY/view?usp=share_link[/video]
 
I wanted to circle back to let you responders know that I succeeded in getting my LED metronome working. Thanks to all for the kind assistance.

...

Great you got it working!

Clicked link - had to sign into g00gle - then needed access ...
 
Back
Top