Using Teensyduino or another language like C++

Status
Not open for further replies.

tyguy

New member
Hey all,

Getting started using a teensy for a project with a buddy, but wondering what language we should use. I just took a course on C++, so I wanted to use that, but if it's going to be more of a hassle trying to get it to work I don't know if it's work it. I couldn't find anything concrete on the Teensy 4.0 on the website. We aren't doing anything super difficult. Just need time keeping in the milliscond range and storing adc values to a .txt file. Any tips are greatly appreciated. Thanks!
 
Note: Arduino is C++ with a little hand holding.

That is it uses the GCC C++ compiler to build things. It simply does a little pre-processing of the INO files to do some of the simple things for you like to create forward references and the like.

And your sketch folder can include .cpp and .h and .c files to like to compile using the GCC C and C++ compiler.

Also the Arduino code in the core includes a simple main.cpp that is real simple:
Code:
#include <Arduino.h>

extern "C" int main(void)
{
#ifdef USING_MAKEFILE

	// To use Teensy 4.0 without Arduino, simply put your code here.
	// For example:

	pinMode(13, OUTPUT);
	while (1) {
		digitalWriteFast(13, HIGH);
		delay(500);
		digitalWriteFast(13, LOW);
		delay(500);
	}


#else
	// Arduino's main() function just calls setup() and loop()....
	setup();
	while (1) {
		loop();
		yield();
	}
#endif
}
So disregard the MAKEFILE #ifdef thing you see it simply calls setup() and loops forever calling loop and yield...

And you have another option, to use a makefile to build. The Teensy install program has some example makefiles included that you can adapt to your own project. Or there are other options to use other IDE...
 
Status
Not open for further replies.
Back
Top