Ardunio Memory

Good day, i want to ask if arduino uno run at the following condition for hours

Sketch uses 28,580 bytes (88%) of program storage space. Maximum is 32,256 bytes. Global variables use 1,498 bytes (73%) of dynamic memory, leaving 550 bytes for local variables. Maximum is 2,048 bytes.

it will cause problem? i am using it as timer and to avoid delay function i use millis(); but i face problem where the controller store data on SD card and display on LCD and control relay board by I2C but with time running over hour the LCD display wrong thing(unknown char)! and SD card stop recording (please see the link below) at the following link i reduce the number of timer and variable there, but i just need to know about running at than level of memory! http://forum.arduino.cc/index.php?topic=342204.0 dose this problem result from out off memory where many variable long store large time? best regards

Impossible to say without at least seeing the source.

If you use less than 550 bytes for stack and local variables worst case, it's okay. If you use 551 or more, it's not.

So - does your code allocate lots of local variables? Does it use the String class?

thanks AWOL the code in the link for the timer and the other one in this post,
DrAzzy thanks very much you can take look at the code,

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DHT.h>
#include <DallasTemperature.h>
#include <SD.h>
#include <SPI.h>
#include <EEPROM.h>
DHT dht;
OneWire oneWire(8);
DallasTemperature sensors(&oneWire);
DeviceAddress Thermometer = { 0x28, 0xFF, 0x88, 0x1E, 0x02, 0x15, 0x02, 0x70 }; // Temperature Sensor
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
#define Cont 0x26 // relay board
int PinNo1e = 1;
int PinNo2e = 1;
int PinNo3e = 1;
int PinNo4e = 1;
int PinNo5e = 1;
int PinNo6e = 1;
int PinNo2 = 2;
int PinNo3 = 3;
int PinNo4 = 4;
int PinNo5 = 5;
int Minus = 0;
int Plus = 0;
int Ok = 0;
int Set = 0;
int push=0;
double tempC=0;
int Humid=0;
double val=0;
double SetT;
int SetH;
int SetVent1;
int SetVent2;
int SetTimer1;
int SetTimer2;
int hour=0;
long day=0;
byte binary=0;
long timenw=0;
long timepr1=0;
long timepr2=0;
long timepr3=0;
long timepr4=0;
int Ventc=0;
int Timec1=0;
int Timec2=0;
int rvent=0;
int ovent=0;
int rtimer=0;
int side=0;
void setup() {
  // put your setup code here, to run once:
   dht.setup(6); // data pin 9
   Serial.begin(9600); //(Remove all 'Serial' commands if not needed)
   Wire.begin();
   Wire.write(0x00);
   Wire.write(0x00);
   day=EEPROM.read(6); 
   lcd.begin(20,4);         // initialize the lcd for 20 chars 4 lines, turn on backlight
   lcd.backlight();
   sensors.setResolution(Thermometer, 12);
   pinMode(PinNo2, INPUT);    // declare pushbutton as input
   pinMode(PinNo3, INPUT);    // declare pushbutton as input
   pinMode(PinNo4, INPUT);    // declare pushbutton as input
   pinMode(PinNo5, INPUT);    // declare pushbutton as input
   digitalWrite(PinNo2, HIGH);
   digitalWrite(PinNo3, HIGH);
   digitalWrite(PinNo4, HIGH);
   digitalWrite(PinNo5, HIGH);
    while (!Serial) {
    ; 
    }
    
    pinMode(10, OUTPUT);
    pinMode(4, OUTPUT);
    sprintf(filename,"Log%04d.txt",day);
    if (!SD.begin(4)){
      return;
    }
    
}


void Status(){

     Wire.beginTransmission(Cont);
     binary=B11111111;
     if (PinNo1e==0){
        binary=binary-B00000000;
     }
     if (PinNo2e==0){
        binary=binary-B00000001;
     }
     if (PinNo3e==0){
        binary=binary-B00000010;
     }
     if (PinNo4e==0){
        binary=binary-B00000100;
     }
     if (PinNo5e==0){
        binary=binary-B00010000;
     }
     if (PinNo6e==0){
        binary=binary-B00100000;
     }
     Wire.write(binary); 
     Wire.endTransmission();

}

void button(){
  Set = digitalRead(PinNo2);  // read input value Set
  Ok =  digitalRead(PinNo3);  // read input value Ok
  Plus= digitalRead(PinNo4);  // read input value
  Minus= digitalRead(PinNo5);  // read input value
 if (push>0){
 if(push<7){
 if (Ok== LOW){
  push=push+1;
  
 }
 }else{
 push=0; 
  
 }
 }
}

void normal(){
    float Humid = dht.getHumidity();
    lcd.setCursor(0, 0);
    lcd.print("iBird Machine");
    sensors.requestTemperatures();
    lcd.setCursor(0, 1);
    lcd.print("Temp:");
    lcd.setCursor(5, 1);
    float tempC = sensors.getTempC(Thermometer);
    if(Minus==LOW){
      lcd.print(SetT,1);
    }else{
      lcd.print(tempC,1);
    }
    lcd.print("C");
    if(PinNo2e == 0){
      lcd.print("!");
    }else{
      lcd.print("x");
    }
    lcd.print(" Hum:");
    if(Minus==LOW){
      lcd.print(SetH,1);
    }else{
     lcd.print(Humid, 0);
    }
    lcd.print("%");
    if(PinNo4e == 0){
      lcd.print("!");
    }else{
      lcd.print("x");
    }
    lcd.setCursor(0, 2);
    lcd.print("Vent:");
    if(Minus==LOW){
    lcd.print((float)SetVent1, 0);
    }else{
    lcd.print((timenw-timepr2)/60000);    
    }
    lcd.print("min");
    if(PinNo3e == 0){
      lcd.print("!");
    }else{
      lcd.print("x");
    }
    lcd.print(" Run:");
    lcd.print((float)Ventc,0);
    lcd.print(" ");
    lcd.setCursor(0, 3);
    lcd.print("Turn:");
    if(Minus==LOW){
    lcd.print((float)SetTimer1, 0);
    }else{
     lcd.print((timenw-timepr1)/60000);
    }
    lcd.print("min");
    if(PinNo5e == 0 || PinNo6e == 0){
    lcd.print("!");
    }else{
    lcd.print("x");
    }
    lcd.print(" Run:");
    lcd.print((float)Timec1,0);
    lcd.print(" ");
    delay(750);
  if(Set == LOW&&push==0){
      push=1;
  }
  
}

void loop() {
  // put your main code here, to run repeatedly:
  SDcard();
  SetVal();  
  button();
    if (push >0){
    lcd.clear();
    lcd.setCursor(0, 1);
    }
  if(push==0){
      normal();
      timer1();
      timer2();
      Control1();
  }else if(push==1){
    lcd.print("Temperature Setting");
   // TempSet();
  }else if(push==2){
    lcd.print("Humidity Setting");
   // HumidSet();
  }else if(push==3){
    lcd.print("Vent Timer 1 Setting");
   // Vent1Set();
  }else if(push==4){
    lcd.print("Vent Timer 2 Setting");
   // Vent2Set();
  }else if(push==5){
    lcd.print("Timer 1 Setting");
   // Timer1Set();
  }else if(push==6){
    lcd.print("Timer 2 Setting");
   // Timer2Set();
  }

Status();
       // initialize the lcd for 20 chars 4 lines, turn on backlight
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

while (!Serial) {
    ; 
    }
    if (!SD.begin(4)){
      return;
    }
}
void SetVal(){
  if (SetT > 38.2 || SetT<35.0){
  SetT=37.7;
}
if (SetH < 20 || SetH> 80){
  SetH=60;
}
if (SetVent1 > 120 || SetVent1<5){
  SetVent1=60;
}
if (SetVent2 < 2 || SetVent2 > 60){
  SetVent2=15;
}
if (SetTimer1 > 120 || SetTimer1 <30){
  SetTimer1=90;
}
if (SetTimer2 <0 || SetTimer2>300){
  SetTimer2=8;
}

 if(millis()<=2000){
 if(EEPROM.read(1)<20||EEPROM.read(1)>90||EEPROM.read(2)>120||EEPROM.read(2)<1){
    EEPROM.write(0,(SetT*10)-256);
    EEPROM.write(1,SetH);
    EEPROM.write(2,SetVent1);
    EEPROM.write(3,SetVent2);
    EEPROM.write(4,SetTimer1);
    EEPROM.write(5,SetTimer2); 
 }else{
    SetT=(EEPROM.read(0)+256);
    SetT=SetT/10;
    SetH=EEPROM.read(1);
    SetVent1=EEPROM.read(2);
    SetVent2=EEPROM.read(3);
    SetTimer1=EEPROM.read(4);
    SetTimer2=EEPROM.read(5);
 }
 delay(2000);
}

}

this is the other part of the code

void SDcard(){
  
  float Humid = dht.getHumidity();
  
timenw=millis();
Serial.print(timenw-timepr3);

 // Serial.print(",");
if (timenw-timepr3>=3600000){
  hour=hour+1;
  if(hour==23){
    hour=0;
    day=day+1;
    EEPROM.write(6,day);
    timepr3=timenw;
  }
}
if (timenw-timepr4>=1500)
{
  timepr4=timenw;
  String dataString = "";
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  
  sprintf(filename,"Log%04d.txt",day);
  
  //sprintf(filename,"Log%04d_%04d.txt",day,hour);
  //sprintf(filename,"Log%04d.txt",day);
  File dataFile = SD.open(filename, FILE_WRITE);
  Serial.print(filename);
  //Serial.print(",");
  
  
  // if the file is available, write to it:
  if (dataFile) {
      dataString +="Temperature : ";
      dataString += String(tempC);
      dataString += ",";
      dataString +="Humidity : ";
      dataString += String(Humid);
      dataString += ",";
      dataString +="Vent. : ";
   //   dataString += String(Ventc);
      dataString += ",";
      dataString +="Turnten : ";
  //    dataString += String(Timec1+Timec2);
      dataString += ",";
      dataString += "Day";
   //   dataString += String(day);
      dataString += ",";
      dataString += "Hour";
 //     dataString += String(hour);
      dataString += ";";

    dataFile.println(dataString);
    Serial.print(dataString);
 
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  }
  dataFile.close(); 
}   

}

void Control1(){
   Humid = dht.getHumidity();
   tempC = sensors.getTempC(Thermometer);
  if(SetT<=tempC){
    PinNo2e = 1; /* Heat Off */
  }
  if(SetT+0.5<=tempC){
    PinNo2e = 1; /* Heat Off */
    PinNo3e=0; /* Vent On */
    ovent=0;
    //Ventc=Ventc+1;
  }
  if (SetT+0.2>=tempC){
    if (SetT-0.2>=tempC){
    PinNo2e= 0; /* Heat On */    
    }
    if (ovent==0){
    PinNo3e=1; /* Vent Off */
    ovent=1;
    }
  }
  if (SetH-5>=Humid){
    PinNo4e=0; /* Humid On */
  }else if(SetH<=Humid){
    PinNo4e=1; /* Humid Off */
  }
  
/*  if (SetH+10<Humid){
    
    if(SetT-0.2<=tempC){
      
       PinNo3e=0; // Vent On 
        ovent=0;
      
    }
  }*/
  
}

void timer1(){
  timenw=millis();
  if ((timenw-timepr1)< 0||(timenw-timepr2)< 0){
    timepr1=0;
    timepr2=0;
    timepr3=0;
    timepr4=0;
  }
  if(timenw-timepr1>=SetTimer1*60000){
    rtimer=0;
     if(side==0){
      PinNo6e=0;
    }else if(side==1){
      PinNo5e=0;
    }
     if(rtimer==0){
   if(timenw-timepr1>=SetTimer1*60000+SetTimer2*1000){
      if(PinNo6e==0){
        side=1;
      }
      if(PinNo5e==0){
        side=0;
      }
      PinNo6e=1;
      PinNo5e=1;
      timepr1=timenw;
      rtimer=1;
      Timec1=Timec1+1;
  }
  }
  }

}
void timer2(){
  timenw=millis();

  if(timenw-timepr2>=SetVent1*60000){
   PinNo3e=0;
   if(timenw-timepr2>=(SetVent1*60000+SetVent2*1000)){
   PinNo3e=1;
   Ventc=Ventc+1;
   timepr2=timenw;
  }
  }
  
  

}
void TempSet(){
    lcd.setCursor(0, 2);
    lcd.print((float)SetT);
    lcd.print(" C");
    val=SetT;
    delay(1000);
    while(1){
      button();
    if(Plus==LOW){
      val=val+0.1;
      lcd.setCursor(0, 2);
      lcd.print((float)val);
      delay(250);
    }else if(Minus==LOW){ 
      val=val-0.1;
      lcd.setCursor(0, 2);
      lcd.print((float)val);
      delay(250);
    }
    
    if(Ok==LOW){
      SetT=val;
     // addr=0;
      val=(SetT*10)-256;
      EEPROM.write(0,val);
      delay(250);
      break;
    }else if(Set==LOW){
      push=0;
      break;
    }
    }
    delay(1000);
}

void HumidSet(){
    lcd.setCursor(0, 2);
    lcd.print((float)SetH,0);
    lcd.print(" %"); 
    val=SetH;
    while(1){
      if (val>=90){
        SetH=60;
        break;
      }else if(val<=15){
        SetH=60;
        break;
      }
    button();
    if(Plus==LOW){
      plus();
      lcd.setCursor(0, 2);
      lcd.print((float)val,0);
      delay(50);
    }else if(Minus==LOW){
      minus();
      lcd.setCursor(0, 2);
      lcd.print((float)val,0);
      delay(50);
    }
    
    if(Ok==LOW){
      SetH=val;
      EEPROM.write(1,SetH);
      delay(250);
      break;
    }else if(Set==LOW){
      push=0;
      break;
    }
    
    }
    delay(1000);
}
void Vent1Set(){
    lcd.setCursor(0, 2);
    lcd.print((float)SetVent1,0);
    lcd.print("      min");
    val=SetVent1;
    while(1){
      if (val<=0){
        SetVent1=60;
        break;
      }else if(val>=180){
        SetVent1=60;
        break;
      }
      button();
      
    if(Plus==LOW){
      plus();
      lcd.setCursor(0, 2);
      if (val <10 || val <=99){
      emp();
      }
      lcd.print((float)val,0);
      delay(50);
    }else if(Minus==LOW){
      minus();
      lcd.setCursor(0, 2);
      if (val <10 || val <=99){
      emp();
      }
      lcd.print((float)val,0);
      delay(50);
    }
    
    
    if(Ok==LOW){
      SetVent1=val;
      EEPROM.write(2,SetVent1);
      delay(250);
      break;
    }else if(Set==LOW){
      push=0;
      
      break;
    }
    }
    delay(1000);
}
void Vent2Set(){
    lcd.setCursor(0, 2);
    lcd.print((float)SetVent2,0);
    lcd.print("      Sec");
         val=SetVent2;
    while(1){
      if (val<=0){
        SetVent2=15;
        break;
      }else if(val>=60){
        SetVent2=15;
        break;
      }
      button();
    if(Plus==LOW){
      plus();
      lcd.setCursor(0, 2);
      if (val <10 || val <=99){
      emp();
      }
      lcd.print((float)val,0);
      delay(50);
    }else if(Minus==LOW){
      minus();
      lcd.setCursor(0, 2);
      if (val <10 || val <=99){
      emp();
      }
      lcd.print((float)val,0);
      delay(50);
    }
    
    if(Ok==LOW){
      SetVent2=val;
      EEPROM.write(3,SetVent2);
      delay(250);
      break;
    }else if(Set==LOW){
      push=0;
      
      break;
    }
    }
    delay(1000);
}
void Timer1Set(){
    lcd.setCursor(0, 2);
    lcd.print((float)SetTimer1,0);
    lcd.print("      min");
         val=SetTimer1;
    while(1){
      if (val<=0){
        SetTimer1=60;
        break;
      }else if(val>=180){
        SetTimer1=60;
        break;
      }
      button();
    if(Plus==LOW){
      plus();
      lcd.setCursor(0, 2);
      if (val <10 || val <=99){
      emp();
      }
      lcd.print((float)val,0);
      delay(50);
    }else if(Minus==LOW){
      minus();
      lcd.setCursor(0, 2);
      if (val <10 || val <=99){
      emp();
      }
      lcd.print((float)val,0);
      delay(50);
    }
    
    if(Ok==LOW){
      SetTimer1=val;
      EEPROM.write(4,SetTimer1);
      delay(250);
      break;
    }else if(Set==LOW){
      push=0;
      
      break;
    }
    }
    delay(1000);
}
void Timer2Set(){
    lcd.setCursor(0, 2);
    lcd.print((float)SetTimer2,0);
    lcd.print("      Sec");
         val=SetTimer2;
    while(1){

      if (val<0){
        lcd.setCursor(0, 2);
        SetTimer2=60;
        break;
      }else if(val>=254){
        SetTimer2=60;
        break;
      }
      button();
    if(Plus==LOW){
      plus();
      lcd.setCursor(0, 2);
      if (val <10 || val <=99){
      emp();
      }
      lcd.print((float)val,0);
      delay(250);
    }else if(Minus==LOW){
      minus();
      lcd.setCursor(0, 2);
      if (val <10 || val <=99){
      emp();
      }
      lcd.print((float)val,0);
      delay(250);
    }
    
    if(Ok==LOW){
      SetTimer2=val;
      EEPROM.write(5,SetTimer2);
      delay(250);
      break;
    }else if(Set==LOW){
      push=0;
      
      break;
    }
    }
    delay(1000);
}
void plus(){
    val=val+1;  
  delay(250);
}
void minus(){
  val=val-1; 
  delay(250); 
}
void emp(){
 if (val <10 ){
        lcd.print(" ");
      }
      if (val <=99){
lcd.print(" ");
 }
}

please take a look and tell me what is wrong and what you suggest please, because am not really programmer but i can learn quickly
Best regards,
Sayed

Sayed: please take a look and tell me what is wrong and what you suggest please,

If the code is too long for a single Reply please post the .INO file as an attachment.

You have not said what happens when you test your program.

A program could run for years if it never exceeds the memory boundaries and you can ensure that by being careful how you allocate and use memory.

If there is dynamic memory allocation it is possible that it will cause problems after running for some time (maybe minutes, maybe weeks) and it would be impossible (IMHO) to determine that by looking at the code. That's why the professional developers of PC programs need to publish corrected versions when these sorts of problems emerge.

...R

about the long of the code i am new in posting in Ardunio forum that i didnt know that it should attached as ino file thanks for telling me that, and about the problem, i said dear in earlier post that the SD card stop storing the data logger! and i said that the LCD become faulty similar to this photo ( this not my photo but it similar problem) and some time freeze only |500x374 some time when many press on push button it become blank, one more thing what do you mean by dynamic memory allocation? thanks very much for you advice Robin, waiting for others, Best regards

1.

long timenw=0;
long timepr1=0;
long timepr2=0;
long timepr3=0;
long timepr4=0;

Look up mills() what does it return?

2.

if (timenw-timepr3>=3600000){

Wrong! Try printing 3600000 and see what you get.

3.

  // if the file is available, write to it:
  if (dataFile) {
      dataString +="Temperature : ";
      dataString += String(tempC);
      dataString += ",";
      dataString +="Humidity : ";
      dataString += String(Humid);
      dataString += ",";
      dataString +="Vent. : ";
   //   dataString += String(Ventc);
      dataString += ",";
      dataString +="Turnten : ";
  //    dataString += String(Timec1+Timec2);
      dataString += ",";
      dataString += "Day";
   //   dataString += String(day);
      dataString += ",";
      dataString += "Hour";
 //     dataString += String(hour);
      dataString += ";";

    dataFile.println(dataString);
    Serial.print(dataString);

You must NOT build strings like this and then print them out the odds are this is what is killing your program

Use multiple calls to print/println instead.

  1. ALL WAYS AUTO FORMAT YOUR CODE BEFORE POSTING IT.

Mark

thanks very much Mark, 1- the millis give milliseconds since arduino start i use it just to avoid using delay, is there better way if this long wrong in using to store millis or there is a way to do timing other than this? 2- how to do it if that dose not work? i divide both side by 1000 is that ok and solve the problem? 3- how to do it i didnt know other way could you help me more in rewriting it? 4-what do you mean by auto format. thanks you very much for your response. Best regards,

4-what do you mean by auto format.

The IDE has a Tools menu. One of the items on the menu is Auto Format,

3- how to do it i didnt know other way could you help me more in rewriting it?

Why do you need help doing

dataFile.print("Temperature: ");
dataFile.print(TempC);

etc.?

holmes4: 2.

if (timenw-timepr3>=3600000){

Wrong! Try printing 3600000 and see what you get.

I'm unclear what you're saying here.

AWOL: I'm unclear what you're saying here.

He's saying you can't cram a long value into an int variable...

Regards, Ray L.

I don't see any int variables there. I don't get the bit about printing.

UNO-r3 using 1.0.6. But I doubt the version will give you any issues. There are issues doing math when all the numbers are ints but the result is long, but the compiler knows that 3600000 has to be in a long without the l subscript.

void setup(){
  Serial.begin(9600);
  delay(20);
  Serial.println(3600000);
}

void loop(){}

Results:

3600000

PaulS:
The IDE has a Tools menu. One of the items on the menu is Auto Format,
Why do you need help doing

dataFile.print("Temperature: ");

dataFile.print(TempC);



etc.?

thanks Paul, sorry that only i understand first point and it help me, thanks again,

AWOL:
I’m unclear what you’re saying here.

thanks AWOL,
this is timer to run if the time deference greater or equal to that amount in millisecond,
which will control ventilation,

RayLivingston:
He’s saying you can’t cram a long value into an int variable…

Regards,
Ray L.

thanks Ray, i use long to store millisecond as it suggested in some tutorials in order
to avoid using of delay to perform task,

Delta_G:
UNO-r3 using 1.0.6. But I doubt the version will give you any issues. There are issues doing math when all the numbers are ints but the result is long, but the compiler knows that 3600000 has to be in a long without the l subscript.

void setup(){

Serial.begin(9600);
  delay(20);
  Serial.println(3600000);
}

void loop(){}




Results:


3600000

i am using now Arduino 1.6.5 software version is it problem in it?
i just see that Arduino work in controlling temperature and humidity without problem,
just the LCD not working right and SD card stop working,
thanks very much all,
and sorry for my poor English,

Sayed: thanks Ray, i use long to store millisecond as it suggested in some tutorials in order to avoid using of delay to perform task,

Except millis() returns an unsigned long.... Using long will, eventually, give you an incorrect result. And if you're going to compare to a literal with a value of 360,000, you have to use 360000L, or the 360000 will be converted to int before the compare, which will give an incorrect result.

Regards, Ray L.

Sayed: about the long of the code i am new in posting in Ardunio forum that i didnt know that it should attached as ino file thanks for telling me that,

I don't see where you have acted on the advice and posted the .INO file

one more thing what do you mean by dynamic memory allocation?

There are various ways to do this in C/C++ but the most likely situation where it happens is when you use Strings (with a capital S). In the small Arduino memory you should only use strings (small s) which are char arrays terminated with 0

Have a look at how millis() is used in several things at a time.

All variables associated with millis() should be created as unsigned long

...R

RayLivingston:
And if you’re going to compare to a literal with a value of 360,000, you have to use 360000L, or the 360000 will be converted to int before the compare, which will give an incorrect result.

No, again this is a misunderstanding of the problem with ints and longs.

If one of the numbers is a long, then the math gets done with longs and you’re OK. The problem is when all of the numbers are ints. When you do the comparison with a literal value of 3600000 then the compiler knows up front that has to be a long since it is bigger than will fit into an int and it handles that without the L subscript.

For example, this code:

void setup(){
  Serial.begin(9600);
  delay(20);
  Serial.println(100 * 100000);
  Serial.println(100000 * 100);
  unsigned long a = 100 * 100000;
  Serial.println(a);
  if(a < 20000000){
    Serial.println("It's less than");
  } else {
    Serial.println("Something failed");
  }
}
  
void loop(){}

Produces this result:

10000000
10000000
10000000
It's less than

The compiler has no problems with literal numbers larger than will fit into an int.

The problem arises when there isn’t a number like that in the expression but the result or some intermediate result is. For example, this would have failed:

if(a < (20 * 1000 * 1000))

because none of those numbers is too large to fit into an int so the math is all done with ints. This is the case where you must tell the compiler to use a long for one of those variables.

if(a < (20ul * 1000 * 1000))

RayLivingston: Except millis() returns an unsigned long.... Using long will, eventually, give you an incorrect result. And if you're going to compare to a literal with a value of 360,000, you have to use 360000L, or the 360000 will be converted to int before the compare, which will give an incorrect result.

Regards, Ray L.

Robin2: I don't see where you have acted on the advice and posted the .INO file

There are various ways to do this in C/C++ but the most likely situation where it happens is when you use Strings (with a capital S). In the small Arduino memory you should only use strings (small s) which are char arrays terminated with 0

Have a look at how millis() is used in several things at a time.

All variables associated with millis() should be created as unsigned long

...R

thanks, i just note that i am missing unsigned before long, and about the string when i change it to small letter it dose not work for me, any idea?

Sayed:
and about the string when i change it to small letter it dose not work for me, any idea?

string with a small letter is spelled char*.