05-13-2020, 08:22 AM
If I want to add a few more buttons, I just have to add a few more paragraphs like this to the file,
elif str(row['id']) == '8' and row['enabled'] == '1':
sw_8_pin = int(row['pin'])
sw_8_cmd = row['command'].split(' ')
GPIO.setup(sw_8_pin,GPIO.IN, pull_up_down=GPIO.PUD_UP)
def sw_8_event(channel):
subprocess.call(sw_8_cmd)
GPIO.add_event_detect(sw_8_pin, GPIO.RISING, callback = sw_8_event, bouncetime = bounce_time)
print str(datetime.datetime.now())[:19] + ' sw_8: pin=' + str(sw_8_pin) + ', enabled=' + row['enabled'] + ', bounce_time=' + str(bounce_time) + ', cmd=' + row['command']
only change the numbers to "9", "10", etc. Isnt it?
elif str(row['id']) == '8' and row['enabled'] == '1':
sw_8_pin = int(row['pin'])
sw_8_cmd = row['command'].split(' ')
GPIO.setup(sw_8_pin,GPIO.IN, pull_up_down=GPIO.PUD_UP)
def sw_8_event(channel):
subprocess.call(sw_8_cmd)
GPIO.add_event_detect(sw_8_pin, GPIO.RISING, callback = sw_8_event, bouncetime = bounce_time)
print str(datetime.datetime.now())[:19] + ' sw_8: pin=' + str(sw_8_pin) + ', enabled=' + row['enabled'] + ', bounce_time=' + str(bounce_time) + ', cmd=' + row['command']
only change the numbers to "9", "10", etc. Isnt it?