Total newbie to Pi and coding, I have plans on wiring my new house with the Pi and am trying to learn the basics.
I am attempting to wire a Reed switch and when it is activated turn an LED on and print the time and date that it was activated.
I have successfully been able to do this but it will continuously print the statement out until the reed switch is re-opened.
How can I re-work my code so it will only print the statement out once and then re-print it with the updated time once each time the reed switch switch is closed.
my code is:
import RPi.GPIO as GPIO
GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
localtime = time.asctime( time.localtime(time.time()) )
Thank you for your help!