Running out of memory - suggestions?

I get the following compile message: Warning: Large amount of SRAM memory used. Consider using PROGMEM or F("text") macro to reduce ram usage. I only use one small int array (int x[2]). What is PROGMEM or F("text") macro and how do I use in my sketch? Any suggestions on reducing memory in my sketch?

Binary sketch size: 21,150 bytes (of a 32,256 byte maximum) Estimated used SRAM memory: 1,464 bytes (of a 2048 byte maximum)

I can't insert my code because "The message will exceed the maximum allowed length (9500 characters)".

I can't insert my code because "The message will exceed the maximum allowed length (9500 characters)".

Click on "Additional Options..." when replying. Then attach your code to the message.

Or post first part of your code first. My ipad can't open attachment. My android phone is too slow.

 I only use one small int array (int x[2]).

Yes but do you have strings? eg.

Serial.println ("The results of the calculations are:");

Not many fixed strings but I can delete them. Attached is my sketch:

My_Robot_20.ino (18.4 KB)

warren631: Not many fixed strings but I can delete them. Attached is my sketch:

A quick scan through didn't reveal an excessive amount of global data, but you have several dozen string literals which could add up to a few hundred bytes - in this environment, that's a lot.

From this page: http://www.arduino.cc/playground/Main/Printf

Using Flash Memory for string storage

Version 1.0 of the Arduino IDE introduced the F() syntax for storing strings in flash memory rather than RAM. e.g.

Serial.println(F("This string will be stored in flash memory"));

Another thing to consider is how much SRAM those libraries are consuming.

Finally, I notice that currentMillis is never used, although you assign to it. I'm not sure if the compiler is smart enough to drop the declaration. Do you perhaps have others that are (currently) unused?

Many libs (6), short code, large compile size =>> you are using too many libraries. Use a MEGA.

Some values in your code could be declared as bool, for example: int hitLeft = 1;

And some other values could be declared as byte, for example: int maxSpd = 100;

You will gain few bytes by using the correct types... :)

Note that this warning appear as soon as you use more than half the available memory.

guix: Note that this warning appear as soon as you use more than half the available memory.

Is this the Arduino 1.5 thing? I have not tried this version yet.

warren631: I get the following compile message: Warning: Large amount of SRAM memory used. Consider using PROGMEM or F("text") macro to reduce ram usage. I only use one small int array (int x[2]).

You don't just count arrays. I counted about 32x int, 10x float, 8x unsigned long. That's 136 bytes already. Plus as others said, the libraries would use RAM as well.

warren631: Binary sketch size: 21,150 bytes (of a 32,256 byte maximum) Estimated used SRAM memory: 1,464 bytes (of a 2048 byte maximum)

Things aren't desperate yet. You have 500 bytes in hand.

liudr: Is this the Arduino 1.5 thing? I have not tried this version yet.

You on a Mac? I tried it yesterday and got this:

No I have a PC. The only apple thing I have the my ipad 2.

Oh, right. Then you would get a different message. ;)

http://arduino.cc/forum/index.php?topic=130965

liudr: Is this the Arduino 1.5 thing? I have not tried this version yet.

No it is with the Arduino Enhanced IDE :)

Will test it out.

Running out of memory - suggestions?

Two highly effective and absolutely sure ways to solve this problem:

1) shrink your code; 2) move to a bigger chip.

liudr: Will test it out.

Arduino 1.5.1 r2 runs normally on my windows 7, 32 bit machine. I don't have an arduino at hand to test the upload but code compiles fine.

warren631: Not many fixed strings but I can delete them. Attached is my sketch:

The warning message from the IDE very helpfully told you the first thing you needed to do, i.e. use the F() macro for all those string literals you pass to Serial.print() and Serial.println(). Looking at your code, I see that you have ignored that advice. Why are you asking for help here instead? If you don't understand what the message is suggesting, and can't understand it after doing some research, you should say so.

If you don't understand what the message is suggesting, and can't understand it after doing some research, you should say so.

Hello...I thought I did say so:

What is PROGMEM or F("text") macro and how do I use in my sketch?