@@ -35,15 +35,15 @@ Usage Example
35
35
=============
36
36
37
37
38
- Single Ended
39
- ------------
38
+ MCP3008 Single Ended
39
+ ---------------------
40
40
41
41
.. code-block :: python
42
42
43
43
import busio
44
44
import digitalio
45
45
import board
46
- from adafruit_mcp3xxx.mcp3008 import MCP3008
46
+ import adafruit_mcp3xxx.mcp3008 as MCP
47
47
from adafruit_mcp3xxx.analog_in import AnalogIn
48
48
49
49
# create the spi bus
@@ -52,42 +52,95 @@ Single Ended
52
52
# create the cs (chip select)
53
53
cs = digitalio.DigitalInOut(board.D5)
54
54
55
- # create the mcp object from MCP3008 class
56
- mcp = MCP3008(spi, cs)
55
+ # create the mcp object
56
+ mcp = MCP . MCP3008(spi, cs)
57
57
58
58
# create an analog input channel on pin 0
59
- chan = AnalogIn(mcp, MCP3008 .pin_0 )
59
+ chan = AnalogIn(mcp, MCP .P0 )
60
60
61
61
print (' Raw ADC Value: ' , chan.value)
62
62
print (' ADC Voltage: ' + str (chan.voltage) + ' V' )
63
63
64
64
65
- Differential
66
- ------------
65
+ MCP3008 Differential
66
+ --------------------
67
67
68
68
.. code-block :: python
69
69
70
70
import busio
71
71
import digitalio
72
72
import board
73
- from adafruit_mcp3xxx.mcp3008 import MCP3008
74
- from adafruit_mcp3xxx.differential_analog_in import DifferentialAnalogIn
73
+ import adafruit_mcp3xxx.mcp3008 as MCP
74
+ from adafruit_mcp3xxx.analog_in import AnalogIn
75
75
76
76
# create the spi bus
77
77
spi = busio.SPI(clock = board.SCK , MISO = board.MISO , MOSI = board.MOSI )
78
78
79
79
# create the cs (chip select)
80
80
cs = digitalio.DigitalInOut(board.D5)
81
81
82
- # create the mcp object from MCP3008 class
83
- mcp = MCP3008(spi, cs)
82
+ # create the mcp object
83
+ mcp = MCP . MCP3008(spi, cs)
84
84
85
- # create a differential analog input channel with pin 0 and pin 1
86
- chan = DifferentialAnalogIn (mcp, MCP3008 .pin_0, MCP3008 .pin_1 )
85
+ # create a differential ADC channel between Pin 0 and Pin 1
86
+ chan = AnalogIn (mcp, MCP .P0, MCP .P1 )
87
87
88
88
print (' Differential ADC Value: ' , chan.value)
89
89
print (' Differential ADC Voltage: ' + str (chan.voltage) + ' V' )
90
90
91
+ MCP3004 Single-Ended
92
+ ---------------------
93
+
94
+ .. code-block :: python
95
+
96
+ import busio
97
+ import digitalio
98
+ import board
99
+ import adafruit_mcp3xxx.mcp3004 as MCP
100
+ from adafruit_mcp3xxx.analog_in import AnalogIn
101
+
102
+ # create the spi bus
103
+ spi = busio.SPI(clock = board.SCK , MISO = board.MISO , MOSI = board.MOSI )
104
+
105
+ # create the cs (chip select)
106
+ cs = digitalio.DigitalInOut(board.D5)
107
+
108
+ # create the mcp object
109
+ mcp = MCP .MCP3004(spi, cs)
110
+
111
+ # create an analog input channel on pin 0
112
+ chan = AnalogIn(mcp, MCP .P0, MCP .P1)
113
+
114
+ print (' Raw ADC Value: ' , chan.value)
115
+ print (' ADC Voltage: ' + str (chan.voltage) + ' V' )
116
+
117
+ MCP3004 Differential
118
+ --------------------
119
+
120
+ .. code-block :: python
121
+
122
+ import busio
123
+ import digitalio
124
+ import board
125
+ import adafruit_mcp3xxx.mcp3004 as MCP
126
+ from adafruit_mcp3xxx.analog_in import AnalogIn
127
+
128
+ # create the spi bus
129
+ spi = busio.SPI(clock = board.SCK , MISO = board.MISO , MOSI = board.MOSI )
130
+
131
+ # create the cs (chip select)
132
+ cs = digitalio.DigitalInOut(board.D5)
133
+
134
+ # create the mcp object
135
+ mcp = MCP .MCP3004(spi, cs)
136
+
137
+ # create a differential ADC channel between Pin 0 and Pin 1
138
+ chan = AnalogIn(mcp, MCP .P0, MCP .P1)
139
+
140
+ print (' Differential ADC Value: ' , chan.value)
141
+ print (' Differential ADC Voltage: ' + str (chan.voltage) + ' V' )
142
+
143
+
91
144
92
145
Contributing
93
146
============
0 commit comments