I have a Arduino Uno with a program that is around 14,000 bytes great, so in theory i have enough left.
I have the Uno connectot to a BOE shield with a compass sensor, 3 servos and a BlueSMiRF. For the program i have made a state machine with some functions. In a state i print out some informatation but when i looked at the serial monitor it gives al lot of strange symbols and the program runs wrong. When i remove some code lines then the program gives the write information and runs correctly? Is this a memory problem? Because when i remove some code lines the program works fine, and how do i check if this is a memory problem?
Yes you are ofcourse right! the lines that i removed where prints, so this also has impact on the RAM? When the Uno runs out of RAM does is give strange sybols in the serial print?\
@majenko: Maby a stupid question but why? Do strings take up a lot of memory?
Yes you are ofcourse right! the lines that i removed where prints, so this also has impact on the RAM? When the Uno runs out of RAM does is give strange sybols in the serial print?
When ram is overrun just about anything wierd can happen, none of which are useful. Note that you can store constant string messages in program memory (flash memory) and print them out from there, thus unburdening the ram use in your sketch.
int freeRam () {
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
String objects use dynamic allocation. They can mess up your heap and waste bytes besides the overhead they use.
When you have 2k for heap and stack, using C++ String objects is like having truck races in a 2 acre field. You can but it's not going to be pretty.