Mar-30-2017, 10:19 PM
You can greatly simplify your code:
import time GPIO.setmode(GPIO.BCM) pinlist = [2,3,4,17,27,22,10,9] GPIO.setup(pinlist, GPIO.OUT) GPIO.output(pinlist,GPIO.HIGH) def main(): port_sequence = { 'Rounds': [2, 3, 4, 17, 27, 22, 10, 9], 'Queens': [22, 4, 27, 10, 3, 17, 22, 9], 'RQueens': [10, 27, 4, 2, 3, 17, 22, 9], 'Titums': [2, 27, 3, 22, 4, 10, 17, 9] } SleepA = 0.2 SleepB = 1 def play_tune(name): print(name) for val in port_sequence[name]: GPIO.output(val, GPIO.LOW) time.sleep(SleepA); GPIO.output(val, GPIO.HIGH) time.sleep(SleepA); GPIO.cleanup() for name in ['Rounds','Queens','RQueens','Titums']: play_tune(name) count = 0 while count < 2: random.choice(Tune)() count += 1 if count > 2: break main()I am unable to test