Lesson 78: Using VL53L0X Laser Distance Sensor with LCD1602 or LCD2004 Display with Arduino
Related or required files and link to this lesson
- VL53L0X Library from Roboj.com (zip)
- LCD1602 Library from Robojax.com
- VL53L0X Datasheet (pdf)
- View VL53L0X on GitHub
Part 8: Obstacle Avoidance with Arduino
In this lesson we learn how to use VL53L0X 200cm laser ToF (Time of Flight) distance sensor using Arduino. We will display the distance on the LCD1602 LCD display. the module is explained, wiring diagram shown and wiring is explained. Code is fully explained and demonstrated. this code is for single sensor.
- 00:00 Start
- 00:56 Introduction
- 04:30 VL6080V Datasheet viewed
- 06:58 Wiring shown
- 07:32 Wiring for two or more sensors
- 09:22 Installing library
- 10:30 Arduino code explained (1 sensor)
- 12:57 Code for 2 or more sensors
- 19:35 Demonstration 1 sensor
- 22:05 Demonstration with 2 sensors
/*
* Lesson 76-1: Using One single VL6180 Laser Distance Sensor with Arduino
* Adafruit code modified for this tutorial
* by Ahmad Shamshiri at 22:22 on
* Mar 10-11, 2021 in Ajax, ON, Canada
Please watch video instruciton of this code : https://youtu.be/_H9D0czQpSI
View code for using two or more VL6180X sensors: https://robojax.com/course1/lecture76
This video is part of Arduino Step by Step Course which starts here: https://youtu.be/-6qSrDUA5a8
If you found this tutorial helpful, please support me so I can continue creating
content like this. You can support me on Patreon http://robojax.com/L/?id=63
or make donation using PayPal http://robojax.com/L/?id=64
* This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.*
* This code has been download from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <Wire.h>
#include "Adafruit_VL6180X.h"
Adafruit_VL6180X vl = Adafruit_VL6180X();
void setup() {
Serial.begin(115200);
// wait for serial port to open on native usb devices
while (!Serial) {
delay(1);
}
Serial.println("Adafruit VL6180x test!");
if (! vl.begin()) {
Serial.println("Failed to find sensor");
while (1);
}
Serial.println("Sensor found!");
}
void loop() {
uint8_t range = vl.readRange();
uint8_t status = vl.readRangeStatus();
if (status == VL6180X_ERROR_NONE) {
Serial.print("Range: "); Serial.print(range);
Serial.println("mm");
}
// if(range <=76)
// {
// //do something
// }
// Some error occurred, print it out!
if ((status >= VL6180X_ERROR_SYSERR_1) && (status <= VL6180X_ERROR_SYSERR_5)) {
Serial.println("System error");
}
else if (status == VL6180X_ERROR_ECEFAIL) {
Serial.println("ECE failure");
}
else if (status == VL6180X_ERROR_NOCONVERGE) {
Serial.println("No convergence");
}
else if (status == VL6180X_ERROR_RANGEIGNORE) {
Serial.println("Ignoring range");
}
else if (status == VL6180X_ERROR_SNR) {
Serial.println("Signal/Noise error");
}
else if (status == VL6180X_ERROR_RAWUFLOW) {
Serial.println("Raw reading underflow");
}
else if (status == VL6180X_ERROR_RAWOFLOW) {
Serial.println("Raw reading overflow");
}
else if (status == VL6180X_ERROR_RANGEUFLOW) {
Serial.println("Range reading underflow");
}
else if (status == VL6180X_ERROR_RANGEOFLOW) {
Serial.println("Range reading overflow");
}
delay(50);
}