File tree Expand file tree Collapse file tree 5 files changed +102
-12
lines changed Expand file tree Collapse file tree 5 files changed +102
-12
lines changed Original file line number Diff line number Diff line change 9
9
* .DS_Store
10
10
.eggs
11
11
dist
12
- ** /* .egg-info
12
+ ** /* .egg-info
13
+ .vscode /
Original file line number Diff line number Diff line change @@ -63,16 +63,42 @@ Usage Example
63
63
import adafruit_ds3502
64
64
from analogio import AnalogIn
65
65
66
+ # ###### NOTE ################
67
+ # this example will not work with Blinka/rasberry Pi due to the lack of analog pins.
68
+ # Blinka and Raspberry Pi users should run the "ds3502_blinka_simpletest.py" example
69
+
66
70
i2c = board.I2C()
67
71
ds3502 = adafruit_ds3502.DS3502(i2c)
68
72
wiper_output = AnalogIn(board.A0)
69
73
70
- ds3502.wiper = 127
71
- print (" Wiper value: %d " % wiper_output.value)
72
- sleep(1.0 )
73
-
74
- ds3502.wiper = 0
75
- print (" Wiper value: %d " % wiper_output.value)
74
+ while True :
75
+
76
+ ds3502.wiper = 127
77
+ print (" Wiper set to %d " % ds3502.wiper)
78
+ voltage = wiper_output.value
79
+ voltage *= 3.3
80
+ voltage /= 65535
81
+ print (" Wiper voltage: %.2f " % voltage)
82
+ print (" " )
83
+ sleep(1.0 )
84
+
85
+ ds3502.wiper = 0
86
+ print (" Wiper set to %d " % ds3502.wiper)
87
+ voltage = wiper_output.value
88
+ voltage *= 3.3
89
+ voltage /= 65535
90
+ print (" Wiper voltage: %.2f " % voltage)
91
+ print (" " )
92
+ sleep(1.0 )
93
+
94
+ ds3502.wiper = 63
95
+ print (" Wiper set to %d " % ds3502.wiper)
96
+ voltage = wiper_output.value
97
+ voltage *= 3.3
98
+ voltage /= 65535
99
+ print (" Wiper voltage: %.2f " % voltage)
100
+ print (" " )
101
+ sleep(1.0 )
76
102
77
103
78
104
Contributing
Original file line number Diff line number Diff line change
1
+ from time import sleep
2
+ import board
3
+ import adafruit_ds3502
4
+
5
+ i2c = board .I2C ()
6
+ ds3502 = adafruit_ds3502 .DS3502 (i2c )
7
+
8
+ # As this code runs, measure the voltage between ground and the RW (wiper) pin
9
+ # with a multimeter. You should see the voltage change with each print statement.
10
+ while True :
11
+ ds3502 .wiper = 127
12
+ print ("Wiper value set to 127" )
13
+ sleep (5.0 )
14
+
15
+ ds3502 .wiper = 0
16
+ print ("Wiper value set to 0" )
17
+ sleep (5.0 )
18
+
19
+ ds3502 .wiper = 63
20
+ print ("Wiper value set to 63" )
21
+ sleep (5.0 )
Original file line number Diff line number Diff line change
1
+ from time import sleep
2
+ import board
3
+ import adafruit_ds3502
4
+ from analogio import AnalogIn
5
+
6
+ i2c = board .I2C ()
7
+ ds3502 = adafruit_ds3502 .DS3502 (i2c )
8
+ wiper_output = AnalogIn (board .A0 )
9
+
10
+ ds3502 .wiper = 127
11
+ print ("Wiper value: %d" % wiper_output .value )
12
+ sleep (1.0 )
13
+
14
+ ds3502 .wiper = 0
15
+ print ("Wiper value: %d" % wiper_output .value )
Original file line number Diff line number Diff line change 3
3
import adafruit_ds3502
4
4
from analogio import AnalogIn
5
5
6
+ ####### NOTE ################
7
+ # this example will not work with Blinka/rasberry Pi due to the lack of analog pins.
8
+ # Blinka and Raspberry Pi users should run the "ds3502_blinka_simpletest.py" example
9
+
6
10
i2c = board .I2C ()
7
11
ds3502 = adafruit_ds3502 .DS3502 (i2c )
8
12
wiper_output = AnalogIn (board .A0 )
9
13
10
- ds3502 .wiper = 127
11
- print ("Wiper value: %d" % wiper_output .value )
12
- sleep (1.0 )
14
+ while True :
15
+
16
+ ds3502 .wiper = 127
17
+ print ("Wiper set to %d" % ds3502 .wiper )
18
+ voltage = wiper_output .value
19
+ voltage *= 3.3
20
+ voltage /= 65535
21
+ print ("Wiper voltage: %.2f" % voltage )
22
+ print ("" )
23
+ sleep (1.0 )
24
+
25
+ ds3502 .wiper = 0
26
+ print ("Wiper set to %d" % ds3502 .wiper )
27
+ voltage = wiper_output .value
28
+ voltage *= 3.3
29
+ voltage /= 65535
30
+ print ("Wiper voltage: %.2f" % voltage )
31
+ print ("" )
32
+ sleep (1.0 )
13
33
14
- ds3502 .wiper = 0
15
- print ("Wiper value: %d" % wiper_output .value )
34
+ ds3502 .wiper = 63
35
+ print ("Wiper set to %d" % ds3502 .wiper )
36
+ voltage = wiper_output .value
37
+ voltage *= 3.3
38
+ voltage /= 65535
39
+ print ("Wiper voltage: %.2f" % voltage )
40
+ print ("" )
41
+ sleep (1.0 )
42
+
You can’t perform that action at this time.
0 commit comments