🍞
Breadstick
  • Breadstick Innovations Website
  • Breadsticks
    • đŸĨ–Raspberry Breadstick
      • Code Examples
        • Demo Code
        • POV Wand
        • Pride Flags POV Wand
        • 6-Axis IMU
        • RGB Blink
        • AsyncIO RGB Blink
        • Digital Input
        • Digital Output
        • PWM
        • ADC
        • Servo Motor
    • đŸĨ–Raspberry Breadstick Lite
    • 🍞Support Boards
      • I2C Devices
        • 🚌I2C Bus Rail Adapter
        • đŸŒĻī¸Weather Crouton
        • 😎Brightness Crouton
        • 📏Distance Crouton
        • đŸĢ¨Motion Crouton
      • I2S Devices
        • đŸ“ĸBoombox
      • SPI Devices
      • đŸ•šī¸Buttons/Switches
    • Learning Resources
    • Troubleshooting
  • Nougat
    • Nougat C3
    • Nougat Quad
    • Installing WLED
  • Pico Slices
    • 🔴Slice 1 - LED Mixer
      • Assembly Guide
      • CircuitPython Code
        • 1 - Blink
        • 2 - Analog Read to Plotter
        • 3 - PWM Fade
        • 4 - Pot Controlled PWM
        • 5 - Gamma Correction
    • âąī¸Slice 2 - Stopwatch
      • Assembly Guide
      • Coding Lessons
        • 1 - 7-Segment Display Intro
        • 2 - Cycling Through All Segments
    • âŦœSlice 3 - 8x8 Dot Matrix
      • Assembly Guide
      • MicroPython Code
        • 1 - Moveable Pixel
        • 2 - Snake
    • Circuit Python Setup
    • Reset Bricked Pico
  • Christmas
    • Christmas Tree DIY kit
  • Protoboards
    • â¤ī¸Proto-Heart
    • đŸĨĒProto-Toast
  • SHOP
Powered by GitBook
On this page
  • Product Page
  • Circuit Python Library
  • VL53L4CD Datasheet
  • Code

Was this helpful?

  1. Breadsticks
  2. Support Boards
  3. I2C Devices

Distance Crouton

VL53L4CD Time-of-Flight High Accuracy Proximity Sensor (0-1300mm)

PreviousBrightness CroutonNextMotion Crouton

Last updated 1 year ago

Was this helpful?

Product Page

Circuit Python Library

VL53L4CD Datasheet

Code

"""
Distance Crouton (VL53L4CD) Demo Code
Breadstick Innovations
April 16, 2024
https://learn.breadstick.ca/breadstick/breadsticks/support-boards/i2c-devices/distance-crouton
"""

import board
import time
import adafruit_vl53l4cd

crouton_i2c = board.I2C()  # Default Breadstick I2C pins D11(SCL) & D12(SDA)
vl53 = adafruit_vl53l4cd.VL53L4CD(crouton_i2c)

# OPTIONAL: can set non-default values
vl53.inter_measurement = 0
vl53.timing_budget = 50

print("VL53L4CD Simple Test.")
print("--------------------")
model_id, module_type = vl53.model_info
print("Model ID: 0x{:0X}".format(model_id))
print("Module Type: 0x{:0X}".format(module_type))
print("Timing Budget: {}".format(vl53.timing_budget))
print("Inter-Measurement: {}".format(vl53.inter_measurement))
print("--------------------")

vl53.start_ranging()

while True:

    #while not vl53.data_ready:
    #    pass
    vl53.clear_interrupt()

    distance = vl53.distance

    plotter_data = (distance,)  # Mu's Plotter only displays tuples, this is a single object tuple
    print(plotter_data)

    print(f'Distance: {distance} cm')
    print("")

    time.sleep(0.1)

🍞
📏
https://github.com/adafruit/Adafruit_CircuitPython_VL53L4CD
https://www.st.com/resource/en/datasheet/vl53l4cd.pdf
https://shop.breadstick.ca/products/distance-crouton