Add example to demo ADC channel usage
authorPhil Howard <phil@gadgetoid.com>
Fri, 12 Jul 2019 12:54:25 +0000 (13:54 +0100)
committerPhil Howard <phil@gadgetoid.com>
Fri, 12 Jul 2019 12:54:25 +0000 (13:54 +0100)
examples/adc.py [new file with mode: 0755]

diff --git a/examples/adc.py b/examples/adc.py
new file mode 100755 (executable)
index 0000000..c4cf45c
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+import time
+from enviroplus import gas
+
+print("""adc.py - Print readings from the MICS6814 Gas sensor.
+
+Press Ctrl+C to exit!
+
+""")
+
+gas.enable_adc()
+gas.set_adc_gain(4.096)
+
+try:
+    while True:
+        readings = gas.read_all()
+        print(readings)
+        time.sleep(1.0)
+except KeyboardInterrupt:
+    pass