From: Phil Howard Date: Fri, 7 Jun 2019 11:04:09 +0000 (+0100) Subject: Added examples X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02-2.git/commitdiff_plain/0cf10e5bb8354458b6eac7d04d4aa6235bedcf73?ds=inline Added examples --- diff --git a/examples/gas.py b/examples/gas.py new file mode 100755 index 0000000..6da2a65 --- /dev/null +++ b/examples/gas.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +import time +from envirophatplus import gas + + +print("""gas.py - Print readings from the MICS6812 Gas sensor. + +Press Ctrl+C to exit! + +""") + +try: + while True: + readings = gas.read_all() + print(readings) + time.sleep(1.0) +except KeyboardInterrupt: + pass diff --git a/examples/light.py b/examples/light.py new file mode 100755 index 0000000..aa895f1 --- /dev/null +++ b/examples/light.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +import time +import ltr559 + + +print("""light.py - Print readings from the LTR559 Light & Proximity sensor. + +Press Ctrl+C to exit! + +""") + +try: + while True: + lux = ltr559.get_lux() + prox = ltr559.get_proximity() + print("""Light: {:05.02f} Lux +Proximity: {:05.02f} +""".format(lux, prox)) + time.sleep(1.0) +except KeyboardInterrupt: + pass diff --git a/examples/particles.py b/examples/particles.py new file mode 100755 index 0000000..f34e0d4 --- /dev/null +++ b/examples/particles.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +import time +from pms5003 import PMS5003 + + +print("""particles.py - Print readings from the PM5003 Particle sensor. + +Press Ctrl+C to exit! + +""") + +pms5003 = PMS5003() +time.sleep(1.0) + + +try: + while True: + readings = pms5003.read() + print(readings) + time.sleep(1.0) +except KeyboardInterrupt: + pass