You could just use a switch inline with the LED.thats kinda the idea. when said "thing" rolls off the switch, light turns on. when said "thing" rolls back onto it and "sits" on the switch, led off.Also, in your main() function you check to see if the button is pressed and if it is you print the message and turn the LED on. Now think about what is going to happen when you release the button, your code doesn't do anything if the button isn't pressed so if the LED had been turned on it will stay on on.
Statistics: Posted by ame — Mon Feb 05, 2024 2:44 am