009 - Brickcell TOF VL53L0X | MakeCode Microbit
Introduction
The VL53L0X Time-of-Flight (ToF) sensor is a miniature, highly advanced distance sensor designed to measure distances accurately and quickly. It operates based on the principle of time-of-flight, where it emits a laser or infrared light pulse and measures the time it takes for the light to bounce back after hitting an object. This allows it to calculate the distance to the object in front of it with high precision.
VL53L0X ToF sensors are often used in various applications, including robotics, drones, gesture recognition systems, and even in smartphones for functions like proximity sensing and autofocus in cameras. They offer benefits like fast and accurate distance measurement, compact size, and low power consumption.
Hardware Instruction
Let's explore how to connect the VL53L0X Time-Of-Flight distance sensor to a micro:bit microcontroller and utilize MakeCode for programming.
- Connect the TOF distance sensor GND pin to microbit GND pin.
- Connect the TOF distance sensor VCC pin to microbit VCC pin.
- Connect the TOF distance sensor serial data pin (SDA) to microbit pin 20.
- Connect the TOF distance sensor serial clock pin (SCL) to microbit pin 19.
Software Instruction
Now, let's start into programming the micro:bit to utilize the VL53L0X TOF distance sensor.
- Login to https://makecode.microbit.org/ using your Microsoft account.
- Create a new project by clicking the "New Project" button. You may name it anything you want, I suggest to name it with descriptive name such as "tof-vl53l0x-test".
- Click the "Extensions" block just under the "Math" block.
- Type https://github.com/gbantique/brickcell-tof-vl53l0x/ on the search bar.
- Select the "brickcell-tof-vl53l0x" from the search results. The "tof vl53l0x" block should appear under the "Brickcell" block.
- Copy the code provided below.
1Brickcell.init()
2basic.forever(() => {
3 serial.writeNumber(Brickcell.distance())
4 serial.writeString("\r\n")
5 basic.pause(1000);
6})
- Open a Serial Monitor such as Termite terminal app https://www.compuphase.com/software_termite.htm/. Set the baud rate to 115200 bps.
Or you make a copy of my created project in your MakeCode workspace.
https://makecode.microbit.org/S55676-77516-83467-70824/
Expected Result
If you carefully follow the provided instruction above, you should be able to view the measured distance on the serial terminal every 1000 milliseconds.
Posts in this series
- 016 - Brickcell 8x16 Dot Matrix Display | MakeCode Microbit
- 015 - Brickcell 8x8 Dot Matrix Display | MakeCode Microbit
- 014 - Brickcell CO2 SGP30 | MakeCode Microbit
- 013 - Brickcell Gesture APDS9960 | MakeCode Microbit
- 012 - Brickcell Rotary Encoder | MakeCode Microbit
- 011 - Brickcell RTC DS3231 | MakeCode Microbit
- 010 - Brickcell Gyro MPU6050 | MakeCode Microbit
- 008 - Brickcell Color TCS34725 | MakeCode Microbit
- 007 - Brickcell Pressure BMP280 | MakeCode Microbit
- 006 - Brickcell Weight HX711 | MakeCode Microbit
- 005 - Brickcell Fine Dust | MakeCode Microbit
- 004 - Brickcell Ultrasonic HCSR04 | MakeCode Microbit
- 003 - Brickcell NTC Temperature | MakeCode Microbit
- 002 - Brickcell DHT11 | MakeCode Microbit
- 001 - Brickcell LCD I2C | MakeCode Microbit
No comments yet!