Control Hardware PWM on the Raspberry Pi
Project description
rpi_hardware_pwm
Access the hardware PWM of a RaspberryPi with Python. More lightweight than alternatives.
Installation
- On the Raspberry Pi, add
dtoverlay=pwm-2chan
to/boot/config.txt
. This defaults toGPIO_18
as the pin forPWM0
andGPIO_19
as the pin forPWM1
.- Alternatively, you can change
GPIO_18
toGPIO_12
andGPIO_19
toGPIO_13
usingdtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4
.
- Alternatively, you can change
- Reboot your Raspberry Pi.
- You can check everything is working on running
lsmod | grep pwm
and looking forpwm_bcm2835
- You can check everything is working on running
- Install this library:
sudo pip3 install rpi-hardware-pwm
Examples
from rpi_hardware_pwm import HardwarePWM
pwm = HardwarePWM(0, hz=60)
pwm.start(100) # full duty cycle
pwm.change_duty_cycle(50)
pwm.stop()
History
The original code is from jdimpson/syspwm, We've updated it to Python3 and
made it look like the RPi.GPIO
library's API (but more Pythonic than that.), and we use it in Pioreactor bioreactor system.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file rpi_hardware_pwm-0.1.3.tar.gz
.
File metadata
- Download URL: rpi_hardware_pwm-0.1.3.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7e99c9aef16c4c281d87fb3e7f9e019d3103397c2a3bd4c8f80f4d822e6d5da |
|
MD5 | e4caac211d43b632c68db68036b04437 |
|
BLAKE2b-256 | 0d002490089d3106be7ad0829b59dc2ca694f98341858f58eb7315e5c82fa658 |
File details
Details for the file rpi_hardware_pwm-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: rpi_hardware_pwm-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94049d67bbd3a4947fa9ee78db6630fe3d0ad898ea292ef94eafaca9ae56fb07 |
|
MD5 | fab99b292765dfc7fc91bf72cb9ee1e7 |
|
BLAKE2b-256 | a370f4381e305b4540a39e998a755f6fc86e16891206359819817cfc73e913fa |