CM3-Panel-7-basic technical documentation Buy
This example set the ten level of brightness each 1 sec
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(22, GPIO.OUT)
pwm=GPIO.PWM(22, 100)
pwm.start(0)
for dc in range(0,110,10):
print dc
pwm.ChangeDutyCycle(100-dc)
time.sleep(1)
pwm.stop()
GPIO.cleanup()
Pigpio is a library for the Raspberry Pi which allows control of the General Purpose Input Outputs (GPIO). The main features are:
To install the pigpio utility type:
sudo apt update
sudo apt install pigpio
To install the python-pigpio useful to test the PWM backlight in Python type:
sudo apt install python-pigpio
Run pigpiod
sudo pigpiod -
Try this code example in Python. It wil turn off the screen for 1 sec and the turn on
import pigpio
import time
port=pigpio.pi()
port.write(22,1)
time.sleep(1)
port.write(22,0)
This second example set the brightness level each second
import pigpio
import time
port=pigpio.pi()
port.set_PWM_range(22,100)
# Brightness 25%
port.set_PWM_dutycycle(22,100-25)
time.sleep(1)
# Brightness 50%
port.set_PWM_dutycycle(22,100-50)
time.sleep(1)
# Brightness 75%
port.set_PWM_dutycycle(22,100-75)
time.sleep(1)
# Brightness 100%
port.set_PWM_dutycycle(22,100-100)