Skip to main content

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

Installation is a two step process:

  1. On the Raspberry Pi, add dtoverlay=pwm-2chan to /boot/config.txt. Reboot your Raspberry Pi. This defaults to GPIO_18 as the pin for PWM0 and GPIO_19 as the pin for PWM1. Alternatively, you can change GPIO_18 to GPIO_12 and GPIO_19 to GPIO_13 using dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4.
  • You can check everything is working on running lsmod | grep pwm and looking for pwm_bcm2835
  1. Install this library: sudo pip 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, I've updated it to Python3 and made it look like the RPi.GPIO library's API (but more Pythonic than that.)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rpi_hardware_pwm-0.0.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

rpi_hardware_pwm-0.0.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file rpi_hardware_pwm-0.0.1.tar.gz.

File metadata

  • Download URL: rpi_hardware_pwm-0.0.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for rpi_hardware_pwm-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1a71819a8611997b334742a8d926c019775057b82545c91a1090353a1495b341
MD5 584818a397baa223c48d5ec82679d071
BLAKE2b-256 b47125946b5867bcb660b8a7e726adc5ea684db70f51f31f08913db5e3d5a1f3

See more details on using hashes here.

File details

Details for the file rpi_hardware_pwm-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: rpi_hardware_pwm-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for rpi_hardware_pwm-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe5adf9ed0d178472f5749be9920391f0efaf540627eada5aa112ff9e9ab2aea
MD5 a7d90ffa906f54b81bf9aea0942012ed
BLAKE2b-256 d5d486488249ca0a48d609d9b60f3012c06191f7a0a10ba555a9f0d9b8d4433f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page