File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Basic_Resistor_Sensor_Reading_on_Raspberry_Pi Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Example for RC timing reading for Raspberry Pi
2
+ # using CircuitPython Libraries
3
+
4
+ import time
5
+ import board
6
+ from digitalio import DigitalInOut , Direction
7
+
8
+ RCpin = board .D18
9
+
10
+ while True :
11
+ with DigitalInOut (RCpin ) as rc :
12
+ reading = 0
13
+
14
+ # setup pin as output and direction low value
15
+ rc .direction = Direction .OUTPUT
16
+ rc .value = False
17
+
18
+ time .sleep (0.1 )
19
+
20
+ # setup pin as input and wait for low value
21
+ rc .direction = Direction .INPUT
22
+
23
+ # This takes about 1 millisecond per loop cycle
24
+ while rc .value is False :
25
+ reading += 1
26
+ print (reading )
Original file line number Diff line number Diff line change
1
+ # Basic_Resistor_Sensor_Reading_on_Raspberry_Pi
2
+
3
+ Code to accompany this tutorial:
4
+ https://learn.adafruit.com/basic-resistor-sensor-reading-on-raspberry-pi
You can’t perform that action at this time.
0 commit comments