I tried to run this code on my Arduino Uno clone (which has no function so far and is a shortend version of my programm):
String rules [16][5] ={
{"B0 B5", "", "", "cs S0", "", },
[...]
};
void setup() {
Serial.begin(9600);
String foo = "bar";
Serial.println(foo);
}
void loop() {
}
I left the rules
array out, but it is quite big. It isn't used yet, but it contains rules how to react on certain situations (which should be used later).
As the Arduino IDE gives the following after complilig:
Sketch uses 4316 bytes (13%) of program storage space. Maximum is 32256 bytes.
Global variables use 1174 bytes (57%) of dynamic memory, leaving 874 bytes for local variables. Maximum is 2048 bytes.
When I run this sketch there is nothing on the serial monitor. If it works, there should appear bar
, but it does not. The Arduino sends only a linebreak over the serial, but no text.
When I remove some characters from that array so that there are about 900 bytes the script works and prints bar
to the serial monitor.
So, aren't 874 bytes not enough to store a three-character string? Why does it need 900 bytes to store such a short string?
String
instances are more than just their characters. – Ignacio Vazquez-Abrams Oct 29 '17 at 14:57Serial.print
is usually lost (or garbage). Usual idiom to put awhile (!Serial);
insetup
, before printing anything. Pay attention to the semi-colon. – user31481 Oct 29 '17 at 15:19