We'll be using CircuitPython for this project. Are you new to using CircuitPython? No worries, there is a full getting started guide here.
Adafruit suggests using the Mu editor to edit your code and have an interactive REPL in CircuitPython. You can learn about Mu and its installation in this tutorial.
Install the latest release of CircuitPython, version 4. Follow the instructions here using the appropriate CircuitPython UF2 file.
3) Get the latest 4.0 library pack, unzip it, and drag the libraries you need over into the /lib folder on CIRCUITPY.
For this project you will need the following libraries:
- adafruit_busdevice
- adafruit_lidarlite
- adafruit_ht16k33
When these are installed, your CIRCUITPY/lib directory should look something like:
The code is very simple. Once the hardware is set up, the main loop gets the distance (in cm) from the LIDAR and displays it on the 7-segment display.
# SPDX-FileCopyrightText: 2018 Dave Astels for Adafruit Industries # # SPDX-License-Identifier: MIT """ Rangefinder byuit around the Garmin LidarLite Adafruit invests time and resources providing this open source code. Please support Adafruit and open source hardware by purchasing products from Adafruit! Written by Dave Astels for Adafruit Industries Copyright (c) 2018 Adafruit Industries Licensed under the MIT license. All text above must be included in any redistribution. """ import time import busio import board import adafruit_lidarlite import adafruit_ht16k33.segments i2c = busio.I2C(board.SCL, board.SDA) sensor = adafruit_lidarlite.LIDARLite(i2c) display = adafruit_ht16k33.segments.Seg7x4(i2c) while True: try: display.print(sensor.distance) except RuntimeError as e: # If we get a reading error, just print it and keep truckin' print(e) time.sleep(0.5)
Text editor powered by tinymce.