Fixes a bug with premature triggering and optimises delays in firmware.ino