Hello, Im new to Arduino, just got my 1st one today.
Im waiting on leds and 16x2 lcd to arrive.
i've got a relay module and im playing with the onboard led.
I took the blinky sample script as a base, and I noticed when I complied it said I was using 216 bytes of ram for variables, and that seems kinda excessive.
Im trying to figure out where the memory is being used.
could someone look at this and tell me what is considered a global variable here?
Im thinking the pin/serial settings in setup?
But im curious how it comes up with the 216byte's?
I think I got it, apparently the strings in serial print are considered variables..
I can come up with 216bytes, but only if I remove the 3 " " (spaces)... otherwise I come up with 240bytes.
I think I got it, apparently the strings in serial print are considered variables..
No. They are string literals, which get copied into SRAM (unnecessarily) at run time. Keep that from happening by using the F() macro:
Serial.print(F("Relay On"));
I can come up with 216bytes, but only if I remove the 3 " " (spaces)... otherwise I come up with 240bytes.
There are only 30 bytes in the string literals. There are input and output buffers for the Serial class that occupy SRAM. There are function calls that use space on the stack.
It can be challenging to determine exactly how much SRAM is being used at any given time, since attempting to measure (and report) that changes how much is being used.