Thanks to OlivierLenoir who answered my question earlier about randomisation of a string...
I'm trying to control my servos (10 of them) using the result of the randomisation. I'm sure it's something simple, but I don't know the correct term for this to find the answer.
So I kind of name my servos A to J:
Code: Select all
servoA = PWM(Pin(0))
servoA.freq(50)
servoB = PWM(Pin(1))
Code: Select all
servoA.duty_u16(4500)
Code: Select all
targets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
Code: Select all
count_target = range(len(targets))
for t in count_target:
target = choice(targets)
servo(target).duty_u16(1350)
targets.remove(target)
utime.sleep(1)
print(f'{target}')
Code: Select all
target.duty_16(1350)
So how do I rename the "Object" for PWM with the above? Couldn't find the answer with Google... I've probably misunderstood something.
Thanks in advance!
Adrian