Рет қаралды 1,024
IMPORTANT NOTE: There has been a change to how the library operates, so to avoid an error, after getting a distance reading like this:
distance = distance_sensor.distance
you can then set the None result to a distance of 0 (or any other value you'd like), if an infinity reading is returned. If you don't do this then you'll see that you're getting an error when there's nothing in front of the sensor:
if distance == None:
distance = 0
We show how to use the Adafruit VL53L1X Time of Flight Distance Sensor to light up LEDs on a NeoPixel strip as an object approaches, and turn off lights as the object moves away. This is a solution to a challenge presented at the end of the prior video. We also introduce several new CircuitPython commands and techniques including min, max, math.ceil, continue, and f-strings. Finally, the code we create is shown in a fun and beginner-friendly build containing a simple yet beautiful mason jar light that will light up with more lights as the user approaches. Part of Prof. John Gallaugher's CircuitPython School & his university Physical Computing course.