Hello all. I am a very beginner Arduino developer and to be honest this is my first project. I create it on examples from the internet, so it's a bit chaotic and I hit the wall. in my Arduino UNO the memory ran out :(, unfortunately at this stage I am not able to deal with it. Maybe there will be someone who could look at my program and correct the novice's errors? I will be very grateful.
Make sure that all variables are of the appropriate type, ie, are you using ints to hold values that are never greater than 255 for which a byte would be sufficient ?
Use the F() macro when printing strings so that they are stored in program memory
eg
It is a little dispenser intended to help my wife to drop smoking
It give one cigarete and register it, then shows on the screen how long time ago was last one and, when new one is taken it shows how many was today and compare it to yesterday.
I used SD card because I already have it, and it was easiest, might in the future I can swap to eprom.
I have had some issues with char data types, the compiler always was complayning for something
I have changed all printing lines to use sugested F() macro, and now compiler stops at marked line and shows error:
initializer fails to determine size of '__c'
strMinutes=String(minutes);
if (minutes<10) {
strMinutes="0"+String(minutes);
}
lcd.print(F(String(hours)+" "+ strMinutes +"min ago")); <- here
}
else{
Great thanks to you, using F() macros only in string printing lines solved the problem for now, I am going to read how to properly use char string type, and definitely I will apply that in my project.
But now if I can I would like to ask you if I can for another advice.
As you can see I am operating on time stamps many times, I did find that linux time format is easiest for me. But I have problem to do procedure which will check today's date and then read file check each record and compare it to current date and then count all record from yesterday and al records from today. Might can you help me how to do that?
mareckil:
As you can see I am operating on time stamps many times, I did find that linux time format is easiest for me. But I have problem to do procedure which will check today's date and then read file check each record and compare it to current date and then count all record from yesterday and al records from today. Might can you help me how to do that?
The Time library makes that fairly easy.
previousMidnight(time_t) will give you the unix time at the start of today.
The pre-defined constant SECS_PER_DAY can be subtracted from previousMidnight() of today to give the start of yesterday.
Then it is just a process of comparing to see if a given time is between those two times.
I have changed all printing lines to use sugested F() macro, and now compiler stops at marked line and shows error:
initializer fails to determine size of '__c'
strMinutes=String(minutes);
if (minutes<10) {
strMinutes="0"+String(minutes);
}
lcd.print(F(String(hours)+" "+ strMinutes +"min ago")); <- here
}
else{
You can break that up into separate print() statements, and let print() do the conversion from numeric values to text. When printing a single character, it can be a bit more efficient to use single quotes.
the packs are easy to throw away, the machine will stand on the table and clearly show and remind frequency and quantity, every time she take another cigarete, I hope this will make her aware how much she smokes.
mareckil:
the packs are easy to throw away, the machine will stand on the table and clearly show and remind frequency and quantity, every time she take another cigarete, I hope this will make her aware how much she smokes.