Skip to content

Commit f6f6c06

Browse files
authored
Update mcp3421_simpletest.py
Update example to show gain, resolution and mode setting
1 parent 975d1af commit f6f6c06

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

examples/mcp3421_simpletest.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,21 @@
99

1010
i2c = board.I2C()
1111

12-
adc = ADC.MCP3421(i2c)
12+
adc = ADC.MCP3421(i2c, gain = 1, resolution = 14, continuous_mode = True)
1313
adc_channel = AnalogIn(adc)
14+
# gain, resolution and mode can also be set after instantiation:
15+
16+
# set gain to 1, 2, 4 or 8x
17+
# defaults to 1
18+
# adc.gain = 1
19+
20+
# set resolution to 12, 14, 16 or 18
21+
# defaults to 14
22+
# adc.resolution = 14
23+
24+
# set continuous read mode True or False for one-shot
25+
# defaults to True
26+
# adc.continuous_mode = True
1427

1528
while True:
1629
print(adc_channel.value)

0 commit comments

Comments
 (0)