Reset button - Raspberry Pi Forums


this smart letterbox. how can make gpio 24 button when pressed resets number of letters.

code: select all

 import rpi.gpio gpio import time  gpio.setmode(gpio.bcm) gpio.setwarnings(false) gpio.setup(14, gpio.in, pull_up_down = gpio.pud_down)#door switch gpio.setup(24, gpio.in, pull_up_down = gpio.pud_down) #reset switch gpio.setup(23, gpio.out, initial = gpio.low)#buzzer each mail gpio.setup(15, gpio.out, initial = gpio.low)#green led mail gpio.setup(18, gpio.out, initial = gpio.high)#red led no mail   #date , time of mail = time.strftime("%c")  print("------------------") print("welcome mailbox!") print("------------------") print("you have no mail: "  + now)     def checkmail():     mailcount=0     while true:         if(gpio.input(14) == true):             mailcount=mailcount+1             print('mail recieved:', ,' - have: ', mailcount, 'new mails')             time.sleep(1)                         gpio.output(15, gpio.high)             gpio.output(23, gpio.high)             time.sleep(0.5)             gpio.output(18, gpio.low)                  checkmail()  

something like:

code: select all

if(gpio.input(24) == true):     mailcount=0 


raspberrypi



Comments