fixing value in didigtal pin event handler and mode fix