Created
November 22, 2014 14:42
-
-
Save electronut/191e3cc6225c40570221 to your computer and use it in GitHub Desktop.
For testing the hardware PWM capabilities of the Raspberry Pi Model A+.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
test_HW_PWM.py | |
For testing the hardware PWM capabilities of the Raspberry Pi Model A+. | |
Author: Mahesh Venkitachalam | |
Website: electronut.in | |
""" | |
import wiringpi2 as wiringpi | |
import time | |
print("starting PWM") | |
# use BCM GPIO numbers | |
wiringpi.wiringPiSetupGpio() | |
# enable PWM0 | |
wiringpi.pinMode(18,2) | |
# 25% duty cycle | |
wiringpi.pwmWrite(18, 256) | |
# enable PWM1 | |
wiringpi.pinMode(13,2) | |
# 75% duty cycle | |
wiringpi.pwmWrite(13, 768) | |
# loop | |
while True: | |
try: | |
time.sleep(0.5) | |
except: | |
# clean up | |
wiringpi.pwmWrite(18, 0) | |
wiringpi.pwmWrite(13, 0) | |
print("exiting.") | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment