diff --git a/Proximity_Light/LICENSE b/Proximity_Light/LICENSE new file mode 100644 index 000000000..894681267 --- /dev/null +++ b/Proximity_Light/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Dave Astels + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Proximity_Light/main.py b/Proximity_Light/main.py new file mode 100644 index 000000000..62298a5c8 --- /dev/null +++ b/Proximity_Light/main.py @@ -0,0 +1,31 @@ +import time +import board +import busio +import neopixel +import adafruit_vl53l0x + +TRIGGER_DISTANCE = 500 # number of mm where the light toggles +NEOPIXEL_PIN = board.D1 +NUMBER_OF_PIXELS = 8 + +i2c = busio.I2C(board.SCL, board.SDA) +sensor = adafruit_vl53l0x.VL53L0X(i2c) + +strip = neopixel.NeoPixel(NEOPIXEL_PIN, NUMBER_OF_PIXELS, brightness=1.0, auto_write=False) + +strip.fill((0, 0, 0)) +for i in range(NUMBER_OF_PIXELS): + strip[i] = (64, 64, 64) + strip.show() + time.sleep(0.1) + strip[i] = (0, 0, 0) + strip.show() + +while True: + if sensor.range < TRIGGER_DISTANCE: + strip.fill((255, 255, 255)) + strip.show() + else: + strip.fill((0, 0, 0)) + strip.show() + time.sleep(0.1)