Millis not working


i'm working on making alarm clock using rtc chip, after alarm has been disabled want reset after minute passed time alarm turned off. alarm turned off via registering distance of 20cm ultrasonic sensor. read millis function tried implement it. i'm having issues. whole code pretty long , messy i'm going post small excerpt of i'm implementing.

code: [select]

unsigned long alarmtime_past = 0;
unsigned long alarmtime_current = millis();



if (hour_check == alarm_hour && minute_check == alarm_min && (alarm_switch == 2 || alarm_switch == 1)){
alarm();
alarm_switch = 1;
}


if (alarm_switch == 1 && cm < 20){
alarmoff();
alarm_switch = 0;
alarmtime_past = alarmtime_current;
}

if(alarm_switch == 1 && abs(alarmtime_current - alarmtime_past) >= 60000){
alarm_switch = 2;




when monitor variable alarmtime_current , alarmtime_past on serial monitor 0 both. not sure why, guys can tell me.

i use millis inside 2 interrupt functions button debounce. please let me know if need see more code.

yeah, going need see rest of code.

the use of abs unecessary.  variables unsigned, can positive.  roll over, don't go negative.


Arduino Forum > Using Arduino > Project Guidance > Millis not working


arduino

Comments