-
Notifications
You must be signed in to change notification settings - Fork 5
/
pwm.py
46 lines (35 loc) · 1.16 KB
/
pwm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python3
"""
Program: PWM Test (pwm.py)
Platform: Raspberry Pi
Author: M. Heidenreich, (c) 2020
Description:
This code is provided in support of the following YouTube tutorial:
https://youtu.be/1fKH5PU9eck
This example demonstrates a basic dimming LED technique using gpiozero
and Raspberry Pi GPIO.
THIS SOFTWARE AND LINKED VIDEO TOTORIAL ARE PROVIDED "AS IS" AND THE
AUTHOR DISCLAIMS ALL WARRANTIES INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
"""
from signal import pause
from time import sleep
from gpiozero import PWMLED
left = PWMLED(13)
middle = PWMLED(19)
right = PWMLED(26)
try:
left.value = 1
middle.value = 0.5
right.value = 0.25
pause()
except KeyboardInterrupt:
pass
finally:
left.close()
middle.close()
right.close()