The code you write in the Arduino environment is almost legal C++ already. The main difference is that the Arduino environment generates the header file for you, saving you from writing it (or alternatively, from forward-declaring any functions or global variables that you forward reference).The main flab that the Arduino environment adds is library functions such as digitalRead and digitalWrite. These functions are not very large, however they take a significant amount of time to execute. Direct port access is much faster, and should be used where speed is critical.
In Arduino projects, typically you run out of RAM before you run out of program space. So code flab is not much of a problem, but data flab is. There isn't much data flab in the Arduino library apart from the transmit/receive buffers for the serial port, which you need anyway if you are using it (it's worse on the Mega because there are more serial ports). The main ways to conserve RAM are to avoid using the String class and to store text strings and read-only data tables in PROGMEM.If you are developing code for native AVR processors, you can save 512 bytes of code space by not using the bootloader - just upload your program via ICSP instead.Almost nobody programs microprocessors in assembler these days, except for very short pieces of assembler in an otherwise C or C++ program. gcc is quite good at optimization.
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16