First, today is the first time I have used Python. I used Perl 15 years ago, so very rusty but eager to learn. I'm trying to convert the following lines into a for
loop, using x
to increment ONrelay (so ONrelay0, ONrelay1, ONrelay3, and so on):
cpi6x.setbit(board1, cpi6x.ONrelay0)
time.sleep(.300)
cpi6x.setbit(board1, cpi6x.ONrelay1)
time.sleep(.300)
cpi6x.setbit(board1, cpi6x.ONrelay2)
time.sleep(.300)
cpi6x.setbit(board1, cpi6x.ONrelay3)
time.sleep(.300)
cpi6x.setbit(board1, cpi6x.ONrelay4)
I have tried the following, but not surprisingly it doesn't work.
for x in range(0, 5):
cpi6x.setbit(board1, cpi6x.ONrelay%d) % (x)
time.sleep(.300)
Any help would be much appreciated!