You can create a list of outputs ...And then do this, untested ...If you put your code between [code] ... [/code] tags when posting it will preserve the indentation of your code as above.
Code:
output = [ machine.Pin(15, machine.Pin.OUT), machine.Pin(14, machine.Pin.OUT), machine.Pin(13, machine.Pin.OUT), machine.Pin(9, machine.Pin.OUT), machine.Pin(8, machine.Pin.OUT), machine.Pin(7, machine.Pin.OUT), machine.Pin(6, machine.Pin.OUT), machine.Pin(5, machine.Pin.OUT), machine.Pin(4, machine.Pin.OUT),]Code:
import randomwhile True: if snsr_pir.value() == 0: n = random.randrange(len(output)) output[n].value(1) time.sleep(0.8) output[n].value(0) time.sleep(60)Statistics: Posted by hippy — Tue Aug 05, 2025 7:24 pm