Arduino settings in code, is it possible?

I have different boards (say Arduino UNO, Teensy, ATTiny, ...)

At 99% if you design something it is destinated to a specific board with specific settings.

For example (Teensy):

  • NO USB
  • 72MHz

Once I open the IDE for an ATTiny, the settings on the IDE are set for this chip.
Once I open the Teensy project again, ATTiny is selected. I can change it manually, but then the frequence is reset to 96MHz and the USB is also set again to Serial.

Is there a way to save the chip setting in the .ino file? Maybe as comment, so that the Arduino IDE will change automatically the settings once the project is opened?

Thanks!

Simple answer, nope.

This has been often requested for the standard IDE but no progress on actually adding the feature. However I think there is something of the sort in the Arduino Web Editor, though that does not support Teensy or any ATtiny.

What you can do is to use the Arduino IDE's CLI to make the configuration changes you want. You could write a script/batch file that sets the preferences and also opens the .ino file you want associated with those preferences. For more information see: