help

please can any one help me with my first project. My project is using gyroscope MPU 6050 and Ldr with arduino mega board.
the functions are:-
1- timer that makes a buzzer and a led turns on after 15 minutes
2- gyroscope that starts working after 2 minutes and if the device moves after that the buzzer and the led turns on
3- Ldr that starts working after 2 minutes and if the device moves after that the buzzer and the led turns on.
the problems that i face are :-
1- the main timer is not working after the 15 minutes passes.
2- if i adjust the timer for the gyroscope and the ldr more than 30 seconds they don't work
can any one please fix my codes ??
best regards

main.ino (5.29 KB)

If you post your code,it makes it easier to help.

Remember to use code tags

Try changing

          boomTimeId = boomTimeout.after((FIRE_AFTER_SEC)*(1000), FireBoom, NULL);
          gyroStart  = startGyro.after((START_GYRO_SEC)*(1000), EnableGyro, NULL);

to

          boomTimeId = boomTimeout.after(FIRE_AFTER_SEC * 1000UL, FireBoom, NULL);
          gyroStart  = startGyro.after(START_GYRO_SEC * 1000UL, EnableGyro, NULL);

If none of the operands of an expression is longer than 16 bit, computations are done in 16 bits.
That limits your timeout to 216-1 seconds.

Whandall:
That limits your timeout to 216-1 seconds.

milliSeconds so 32.767 seconds

Ok, the milliseconds was an obvious omission,
but 32.767 is not 216-1 (65535) which is the biggest value that can be passed to .after().

Whandall:
Ok, the milliseconds was an obvious omission,
but 32.767 is not 216-1 (65535) which is the biggest value that can be passed to .after().

Hadn't we decided that the compiler uses a signed int unless otherwise instructed that ranges from -32768 to 32767

Deva_Rishi:
Hadn't we decided that the compiler uses a signed int unless otherwise instructed that ranges from -32768 to 32767

Yeah, you are right, the overflowing negative numbers get extended to 32 bits,
so the maximal value will be 4294967295 (232-1).