Hello, I have a problem with code and I cannot figure out what is wrong. I was working on a simple cycle testing software for motors (using relays) and it works pretty well. I can specify on/off time, with repeating cycles. I can stop the cycle while it is happening as well. I'm not very good at coding arduino, let alone anything so I appreciate the help in advance.
Now I plan to add a hall effect sensor to my setup so that I can get RPM data and datalog it. My issue here is that when I include the SD card library, my serial monitor goes nuts. If I use sample sketches from arduino, the sd card works fine and data is logged.
But once I try to use the library in my code is goes nuts. I haven't even entered any code that uses the SD card, only "#include <SD.h>" which is enough to make it go crazy. I have attached my code below.
If I include the sd library in my code, the serial monitor looks like this
"-----Motor CYCLE SUMMARY-----
110001000201
Total Motor Cycle Time(S) : 7.00
--------- MAIN MENU --------
1 - Add new Motor sequence
2 - Remove Motor sequence
3 - Modify Motor sequence
4 - Execute Motor Cycle
I don't see any code. The SD card uses more than half the RAM an UNO has for block buffering. So you have to take care for the rest of the memory. Probably you use too much of it for print() calls, where you can eliminate RAM usage by using the F() macro.
pylon:
I don't see any code. The SD card uses more than half the RAM an UNO has for block buffering. So you have to take care for the rest of the memory. Probably you use too much of it for print() calls, where you can eliminate RAM usage by using the F() macro.
That makes a lot of sense. My code is too long to post as a reply, so I uploaded it to paste bin.
Hmm I will revise my print() calls, I thought it could have been a memory issue.
Replace all print() and println() calls with constant strings, p.e.
Serial.print("This is the constant string");
with a call that uses the F() macro:
Serial.print(F("This is the constant string"));
This will save you a lot of memory but I don't know if that's enough.
You could use the attachment function of the forum to post code that is larger than the allowed character count of the text input field. Just click on "Additional Options..." below the text entry.
pylon:
Replace all print() and println() calls with constant strings, p.e.
Serial.print("This is the constant string");
with a call that uses the F() macro:
Serial.print(F("This is the constant string"));
This will save you a lot of memory but I don't know if that's enough.
You could use the attachment function of the forum to post code that is larger than the allowed character count of the text input field. Just click on "Additional Options..." below the text entry.