I have a basic programming question which im ashamed to ask after working 1.5 hours on this. Theres a chance I will figure it out if I work 4 more hours on it but im still not sure if that will be the ideal solution rather than asking here.
The entire code involves ws2812b and imu so it's better not paste it here so hopefully you will be able to provide some pointers without it:
I have a sensor, imu which senses motion.
If I sense no motion for 3 seconds I want to do code A.
Else I want to do Code B.
And repeat.
I seem to be lost in millis() and setting and resetting timers and runonce booleans and I don't want to involve any libraries just for this so i would appreciate if anyone fluent in code could give any tips.
Thank you but is it possible to pull this off without functions? Tried but couldnt do it and tried it with functions but couldnt because I need to pass some values to functions...
At the beginning of the check motion, You set timestamp to 0. Everytime you loop this function it do this. Your timestamp = time now will not reset like you think since it will be revert back to 0 instead of the latest Millis.