It sounds very much like what you really want is to map the pieces of your input string to the values of your calls to GPIO.output
. You can do that easily (and with far less code than you currently have) by iterating over the control string:
led_map = {
# This maps each "bit" of your input string to the correct ID for GPIO.
0 : 11,
1 : 12,
2 : 13,
3 : 15
}
for i in xrange(len(y)):
bit = y[i]
GPIO.output(led_map[i], int(bit))
This setup prevents you from having to code each permutation separately (which quickly becomes terrible even with only two or three bits, let alone four or more). Rather than thinking in terms of permutations, you can just consider the bits individually, and perform the appropriate functions on each of them in turn.