View Single Post
Old 2nd Dec 2022, 3:16 pm   #68
Slothie
Octode
 
Join Date: Apr 2018
Location: Newbury, Berkshire, UK.
Posts: 1,287
Default Re: Tesla Programmer

I think const arrays are copied from flash to RAM when the sketch starts (like string literals) and the compiler prevents them from being changed. Const variables are usually optimised away.

If you want to save memory you can use the PROGMEM qualifier that puts the const array in program flash, but requires use of "pgm_read_xxx" access functions to get their values (see this article or similar).

If you have string literals in Serial.print() function calls, surround them in the F() psuedo-function to put them program storage e.d.
Code:
Serial.println(F("This is my program"));
The Serial.print[ln] function does the rest for you.
Slothie is offline