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