Well I now have some LED’s driven by PWM. (and am fast running out of colour combinations in Librecalc…)
from RPi import GPIO as gpio
ENCODER_LEDS = {
‘LS’: {‘red’: 12, ‘green’: 10, ‘blue’:7},
‘SELECT’: {‘red’: 21, ‘green’: 18, ‘blue’:15},
‘BACK’: {‘red’: 16, ‘green’: 19, ‘blue’: 22},
‘CHANNEL’: {‘red’: 8, ‘green’: 11, ‘blue’: 13},
}
for each pin in the above …
pin = gpio.PWM(pin, frequency) sets up a pin
pin.start(100) # sets up the led and sets the start state to off
pin.ChangeDutyCycle(value) # sets brightness value= 0 full on, value = 100 fully off
and after . . .
pin.stop()
gpio.clearup()
is the basis of this in Python.
Encoders certainlt react but I’m not sure it’s all correct . . .
But of course the I/O is all handled by lower level calls and it quickly gets overridden once the programme stops or is interrupted and does not behave nicely if the clearup isn’t run such that it sometimes wont run again on a restart.
So a clean start on a zynth . . . .
Whilst running python prog . . .
and after it’s finished . . .
pin 21 ( GPIO9 SPIO_MISO) runs High (Select Red in my world)
from start up and after the prog runs . …