-
Notifications
You must be signed in to change notification settings - Fork 6
/
example.py
35 lines (32 loc) · 909 Bytes
/
example.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Fake RPi.GPIO example
'''
#______________________________________________________________________
# imports
from RPi import GPIO
#______________________________________________________________________
# globals
channel = 0
frequency = 100
dc = 50
#______________________________________________________________________
# testing functions
GPIO.setmode(GPIO.BCM)
GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.output(channel, GPIO.HIGH)
print(GPIO.input(channel))
GPIO.wait_for_edge(channel, GPIO.RISING)
GPIO.event_detected(channel)
GPIO.add_event_detect(channel)
GPIO.add_event_callback(channel)
GPIO.remove_event_detect(channel)
GPIO.cleanup()
#______________________________________________________________________
# testing PWM
p = GPIO.PWM(channel, frequency)
p.start(dc)
p.ChangeFrequency(frequency/2)
p.ChangeDutyCycle(dc/2)
p.stop()