Project is too large for Arduino Nano

Hello guys. I am amateur programmer and I have got a problem with my sketch. I have finished my code for touch display and arduino but I have got a problem here ... On Arduino MEGA is everything working fine but I need to change it on arduino Nano, but I am getting message that project is too large and there are -209 bytes to success upload to arduino nano. Please can anybody help me to optimize the code ? Really please ... Thanks a lot for help. I must attach the code because it is too large to use in [code /code]

vrabel.ino (14.9 KB)

Why is it necessary (or even desirable) to switch to a Nano? The Mega has become my preferred Arduino board.

Apart from your program being too big have you checked whether you are using features that don't exist on the Nano - for example the extra I/O pins and the extra serial ports?

Please post the exact error message you get when you try to compile for the Nano

...R

Hello I am trying to make 3D Case with touch display and arduino nano to do it smaller then with Mega .. and it is too cheaper ( 10 nano are cheaper then 10 mega :smiley: ) ..

This is error message :The project occupies 31436 bytes (102%) in advance for the program. The maximum is 30720 bytes. Global variables occupy 2263 bytes (110%) dynamic memory, -215 bytes remains for local variables. The maximum is 2048 bytes.

Why are you using Serial.print() all over the place when you have the touchscreen? Remove all those lines, and you should be much closer to your goal.

I have already commented all serials .. if it is in comment then it is not using arduino memory

MarvelSK:
I have already commented all serials ..

Then post what you're actually trying to compile. It's not very helpful otherwise.

Delete your use of the Strings and learn about c-style strings, or "null-terminated arrays".

Perehama:
Delete your use of the Strings and learn about c-style strings, or "null-terminated arrays".

That is a wise comment.

Interestingly, that may make the OP's problem appear worse because I don't think the compiler knows how much memory will be needed by the String class whereas when cstrings are used they will have to be sized at compile time. Of course it only appears to be worse because the program would crash as soon as the String class demanded memory that did not exist.

The OP can use the F() macro to store fixed cstrings in program space rather than is SRAM.

...R

I am looking on tutorials but still I don´t understand what you mean c-style string.

MarvelSK:
I am looking on tutorials but still I don´t understand what you mean c-style string.