unsigned long time1=0;
unsigned long time2=0;
unsigned long prvtime1 = 0;
unsigned long prvtime2 = 0;
bool switch_Status = false;
int differance1 = 0;
int differance2 = 0;
//boolean outHigh = false;
//boolean outLow = false;
void setup() {
// put your setup code here, to run once:
pinMode(3, OUTPUT);
pinMode(10, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print("Switch : ");
switch_Status = digitalRead(10);
Serial.println(switch_Status);
if(switch_Status) // switch_Status == HIGH
{
time1=millis();
if(differance1 != 0)
{
Serial.print("diff1 : ");
Serial.println(differance1);
}
}
else
{
time2=millis();
if(differance2 != 0)
{
Serial.print("diff2 : ");
Serial.println(differance2);
}
}
differance1 = time1-prvtime1;
differance2 = time2-prvtime2;
prvtime1 = time1; // prv time update
prvtime2 = time2;
/*
Serial.print("time1 : ");
Serial.print(time1);
Serial.print(" time2 : ");
Serial.print(time2);
Serial.print(" 1,2 differance : ");
Serial.print(time2 - time1);
Serial.print(" differance1 : ");
Serial.print(millis() - time1);
Serial.print(" differance2 : ");
Serial.print(millis() - time2);
*/
}