As far as I can tell, the standard MicroPython I/O control statements such as: pin6.write_digital(0) do not provide a way to change the pin number "on the fly." Thus a program cannot address a series of I/O pins in a loop as you might with:
while X < 7
pin(x).digital_write(my_list[x])
etc...
Perhaps the compiler-interpreter team could add such a capability to the next code release? Comments welcome.
Poor I/O pin addressing in micro:python
Re: Poor I/O pin addressing in micro:python
Create a list of pins and you're set?
Code: Select all
# CreatePin is a method creating Pin objects
pins = [CreatePin(x) for x in range(len(my_list))]
for pin, value in zip(pins, my_list):
pin.write(value)
-
- Posts: 168
- Joined: Tue Nov 07, 2017 11:45 pm
Re: Poor I/O pin addressing in micro:python
What about
Code: Select all
for p in (pin0, pin3, pin2, pin2):
p.write_digital(1)