thank u now i know this , that arduino doesnt stop time even if u turn off arduino and yes i had bad defined a variable, thing is that i found a library to elapse time if it works like the last coment that would elapse time automatically giving me a unsigned long value starting from 0 if i dont elapse time again it will continue incresing the value that was defined like elapsed
#include <elapsedMillis.h>
// Program to count pulses of an On/Off switch on an interval of time
// when time gets v' intervalo compare pulse with v' pulse1
// resolving the states of if's and changing pinmode to LOW or HIGH
//
int ipin=12; // pin sel like IN
int opin=11; // pin sel like OUT
int statopin=LOW; // Initial state of OUTPIN(13)
elapsedMillis tiempo; // variable time
unsigned long intervalo=15000; // initial interval of time
int pulso= 0; // amount of initial pulse of switchsensor
int amtpulso=300; // amount of initial pulse for comparation
void setup() {
// put your setup code here, to run once:
pinMode(ipin, INPUT); // IN for sensor of revolutions (wheel switch)
pinMode(opin, OUTPUT); // OUT true fals of condition statments
}
void loop() {
// put your main code here, to run repeatedly:
// tiempo=millis()+1500; //Capture time in millis on the variable called tiempo (time)
// Read the amount of ON/OFF sensor
// When ipin sense 1, variable pulse increment on one
// Pulse is a variable like count++
if(digitalRead(ipin)==1){
pulso =pulso+1;
delay (100); // DELAY for no rebound
}
// When tiempo(time) gets the amount of intervalo AND pulso gets amtpulso
// Then state of pin 13 or opin change to HIGH
// Increment the amount of intervalo
// Change the amount of pulsos to compare
// Pulso returns to cero
if ((tiempo == intervalo) && (pulso >= amtpulso)){
intervalo=tiempo+2000;
statopin = HIGH;
pinMode(opin,statopin);
intervalo=tiempo+2000;
amtpulso=200;
pulso=0;
}
// If the time ends
// And variable pulse doents gets amtpulso to compare
// Then the state change or stays on LOW
// increment the amount of intervalo
// Change the amount of pulsos to compare
// Pulso returns to cero
if((tiempo== intervalo)&& (pulso<amtpulso)){
intervalo=intervalo+2000;
statopin = LOW;
pinMode(opin,statopin);
intervalo=intervalo+2000;
amtpulso=200;
pulso=0;
}
}