Skip to main content
Warning: undocumented trick.
Source Link
Edgar Bonet
  • 45.2k
  • 4
  • 42
  • 81

When using the Arduino core library, you normally do not write a    main() function function. Instead, you write setup() and loop() and rely on the core'slibcore's provided main() to callfor calling them.

If you nevertheless want to provide your own main(), then you should call call init(); before your (with no arguments) before you try to use the library. Adding just Adding this single call makes your program work on my Uno.

However, since it does not seem to be officially documented, this trick work for memay not be safe against upgrades in the core library. Writing setup() and loop() should be more future-proof.

When using the Arduino core library, you normally do not write a  main() function. Instead, you write setup() and loop() and rely on the core's provided main() to call them.

If you want to provide your own main(), then you should call init(); before your try to use the library. Adding just this call makes your program work for me.

When using the Arduino core library, you normally do not write a  main() function. Instead, you write setup() and loop() and rely on libcore's provided main() for calling them.

If you nevertheless want to provide your own main(), then you should call init(); (with no arguments) before you try to use the library. Adding this single call makes your program work on my Uno.

However, since it does not seem to be officially documented, this trick may not be safe against upgrades in the core library. Writing setup() and loop() should be more future-proof.

Source Link
Edgar Bonet
  • 45.2k
  • 4
  • 42
  • 81

When using the Arduino core library, you normally do not write a main() function. Instead, you write setup() and loop() and rely on the core's provided main() to call them.

If you want to provide your own main(), then you should call init(); before your try to use the library. Adding just this call makes your program work for me.