Skip to content

Commit c153fcb

Browse files
committed
Add Proximity Light code
1 parent 3fc28ed commit c153fcb

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

Proximity_Light/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Dave Astels
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Proximity_Light/main.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import time
2+
import board
3+
import busio
4+
import neopixel
5+
import adafruit_vl53l0x
6+
7+
TRIGGER_DISTANCE = 500 # number of mm where the light toggles
8+
NEOPIXEL_PIN = board.D1
9+
NUMBER_OF_PIXELS = 8
10+
11+
i2c = busio.I2C(board.SCL, board.SDA)
12+
sensor = adafruit_vl53l0x.VL53L0X(i2c)
13+
14+
strip = neopixel.NeoPixel(NEOPIXEL_PIN, NUMBER_OF_PIXELS, brightness=1.0, auto_write=False)
15+
16+
strip.fill((0, 0, 0))
17+
for i in range(NUMBER_OF_PIXELS):
18+
strip[i] = (64, 64, 64)
19+
strip.show()
20+
time.sleep(0.1)
21+
strip[i] = (0, 0, 0)
22+
strip.show()
23+
24+
while True:
25+
if sensor.range < TRIGGER_DISTANCE:
26+
strip.fill((255, 255, 255))
27+
strip.show()
28+
else:
29+
strip.fill((0, 0, 0))
30+
strip.show()
31+
time.sleep(0.1)

0 commit comments

Comments
 (0)