abu3ali:
Hello all,
if i wrote my code on a file saved to an sd card. can i make the arduino in a way to open that file, read the code and boot it to the arduino? i want to do that since the memory on the arduino uno is not enough for my code.
by the way, i am working on a home automation system that has an ethernet shield attached to the arduino. but the code that i wrote is bigger then the memory available on the arduino.
kindly fin attached the code below. the code is not completed yet. however, the idea is that i am displaying a server to control 8-channel relay and display the values of sensors. in the code attached below, it just shows the control of the 8 channel relay. but the memory is full so i can't add the code to display the sensor values. how can i solve this problem ?
Which type of memory are you running out of size?
An "UNO" provides three types of memory:
-program ("flash") memory: 32KB
RAM/SRAM memory: 2KB (2048 bytes)
EEPROM memory: 1KB (1024 bytes)
When having a quick look at your code, I'm guessing that you are running out of 2KB RAM, most likely caused by putting all string constants ("literal strings") into RAM for using "print" command.
Such like (wasting RAM):
Serial.println("Initializing SD card...");
You can avoid putting the string into RAM by using the F-macro for printing literal strings directly from flash memory:
This is the RAM saving way of printing a literal string constant:
Serial.println(F("Initializing SD card..."));
Check all your code for print/println commands, and if you find print/println with a literal string as the parameter, then change it to use the F-macro!
Learn about the F-macro here:
http://playground.arduino.cc/Learning/Memory
The F-macro is for Atmega based boards like UNO, and it is included in all Arduino IDE versions since 1.0 and above.
Using it can save you a lot of RAM when writing code which prints huge amounts of literal string constants.
2048 bytes of RAM is about using 64 strings @32 bytes each in RAM and you are using 100% of RAM without defining a single variable.
So better learn about using the F-macro with each print/println when printing literal string constants.