How to use Arduino libraries without setup() and loop()

That is the video which made me think that I can code with no setup and no loop :smiley: but I'm in trouble with including libraries.

Hi,

Look up the available RAM in a UNO, then in an ESP32.

It doesn't come down to how much code you can fit in, it comes down to what controller your project requires.
There is no "general purpose" that is why they are programmable.

Describe a "general purpose" code/program?

Tom... :grinning: :+1: :coffee: :australia:

Post your code here ( but please use code tags). You may be doing something in an inefficient way which someone may be able to help with.

:scream:

Seriously? Some Arduino libraries do not work all the time in a pure Arduino environment! Arduino is just a smoke & mirror paradigm as there is still a C++ linker and compiler under the ArduinoIDE. Different cpu architectures often call for different linkers/compilers.

The bottom-line here is that one can write code, use many libraries, compile, link, and successfully upload to a microcontroller without using setup() and loop() but it is an academic exercise and achieves no real value. And when doing so, you forfeit forum support and are on-your-on.

Ray

Really ?

Srsly? Perhaps doing so will mean you won't help, but it certainly does not mean forfeiture of forum support.

a7

Well ... I certainly do not speak for all the thousands but it is IMO completely unreasonable for me to entertain any serious assistance beyond the academic for such deviation from norm.

I will apologize for the presumption in my response, restating that I will offer no serious support in specific case.

Academic discussions and entertaining off-road usage is good fodder but such does distract from assisting those really needing help and are playing by the rules on IDE usage and coding. Worst, as in this case, others are inclined to attempt to deviate from the documented approach and create future forum assistance.

But, that is my opinion.

Ray

That video is ok, but it would have been very easy to only toggle a single output pin, not sure why he skipped over that. He could also have set up a timer to do the delay more precisely.

Some of the program memory savings came from not needing to store the arrays that map the Arduino pin designations to the actual hardware pins, but that means you can not use the hardware abstraction for the pin references, which will break a lot of libraries. The same goes for the elimination of the timing functions, those are an expected convenience when coding for an Arduino.

Completely agree.

My general feeling about avoiding the use of setup() and loop() is that setup() and loop() are the basis of Arduino. If you don't like or want them then you probably need to be looking at using something else which means you won't be using the Arduino IDE, or any of the Arduino core functions, Arduino IDE bundled libraries or 3rd party Arduino libraries.
Most Arduino libraries work with and depend on the Arduino environment and its capabilities.
setup() and loop() are just a very tiny part of that overall environment.

If there is a resource issue, like not enough ram or code space then trying to avoid setup() and loop() as an attempt to reduce resource footprint is not the way to go about solving this problem.

For code intensive applications like GLCD applications, where things like fonts can eat up resources, small resource micro-controllers like the AVR parts that have limited ram and code space sometimes can not be used due to not having enough resources.

--- bill

Thanx you all great people, for your reply.