how to detect the push button
View Single Post
Don't compare btn_on to btn-off, they're not the same. Read the state of the button and save it. Then read the state of the button and compare it to the saved state to detect a change. On a change, perform your action and save the new state.