if mreading is not the same as lastmachineState then you reset your debounce time so your very next if() statement will never be true AND you never update lastmachineState
if mreading is not the same as lastmachineState then you reset your debounce time so your very next if() statement will never be true AND you never update lastmachineState