Add Proximity Light code
This commit is contained in:
parent
3fc28ed7d4
commit
c153fcb7bc
2 changed files with 52 additions and 0 deletions
21
Proximity_Light/LICENSE
Normal file
21
Proximity_Light/LICENSE
Normal file
|
|
@ -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.
|
||||
31
Proximity_Light/main.py
Normal file
31
Proximity_Light/main.py
Normal file
|
|
@ -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)
|
||||
Loading…
Reference in a new issue