i want to limit the values of the date to 12 and 31 respectivly but i cant do it. the piece of code in question is -

if(Y == 0){
pickup_date = (date1[17] * 10 + date1[18]);
if(date1[14] * 10 + date1[15] > 12){
date1[14] = 1;
date1[15] = 2;
Month2 = date1[14] * 10 + date1[15];
if(monthdays[Month2] < pickup_date){
pickup_date = monthdays[Month2];
}
if(now.day() > pickup_date)pickup_date = now.day();
}
}
if(Y == 1){
dropof_date = date2[17] * 10 + date2[18];
if(date2[14] * 10 + date2[15] > 12){
date2[14] = 1;
date2[15] = 2;
Month1 = date2[14] * 10 + date2[15];
if(monthdays[Month1] < dropof_date){
dropof_date = monthdays[Month1];
if(now.day() > pickup_date)pickup_date = now.day() + 1;

rent_calculator.ino (7.09 KB)

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your COMPLETE code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom..

Not sure to understand what you need, but you should have a look at the constrain instruction

i don’t see any comparison to “31” in the code you posted

``````      if(date1[14] * 10 + date1[15] > 12){
date1[14] = 1;
date1[15] = 2;
Month2 = date1[14] * 10 + date1[15];
``````

You should do this

``````Month2 = date1[14] * 10 + date1[15];
if (Month2 < 12) {
Month2 = 12;
date1[14] = 1;
date1[15] = 2;
} else if  (Month2 > 31) {
Month2 = 31;
date1[14] = 3;
date1[15] = 1;
}
``````

Is it what you want ?

"X, Y, date1[14], 48, month2..."

Use descriptive variable names, for example "temperature" instead of "t". You can name numerical constants, pin numbers, variables and many other things in this way. For example, you can refer to a pin and an output level by number, like

``````digitalWrite(3,0)
``````

. But such a statement doesn't reveal anything about the purpose.

``````digitalWrite(hornRelayPin, LOW)
``````

does. You can do that by declaring

``````const byte hornRelayPin = 3;
``````

before setup() in your program. Many such names are already defined for you by the compiler and the Arduino IDE. Here are some:

``````#define HIGH 0x1
#define LOW  0x0
#define PI 3.1415926535897932384626433832795
``````

Use them. There are many more. Use compiler math to compute values so you can see where they came from (or at least document them). For example, if you see the number 73, you would be hard put to explain the significance of it. But if you see "daysPerYear/5", it is obvious. One more thing. When you work on program continuously, you become familiar with it. So many things seem obvious even if they are not spelled out explicitly. But try looking at your own code six months later. It will be as if a stranger wrote it. So write for strangers, not yourself.