Back to Step by Step Course by Robojax

Lesson 79: Using VL53L0X Laser Distance sensors with 4 digit LED dipaly TM1637

If you don't like to see ads while video is being played you can purchase YouTube premium Here

Related or required files and link to this lesson

Part 8: Obstacle Avoidance with Arduino

In this lesson we learn how to wire and use VL53L0X laser ToF range finder, measure the distance and display it on TM1637 4 digits seven segment display. Full wiring diagram shown, code explained and then demonstrated.

  • 00:00 Introduction
  • 00:28 Wiring Explained
  • 03:43 Code Explained
  • 06:00 Demonstration

 
/* 
 * S08-10 VL53L0X with TM1637
* Lesson 79: Using VL53L0X Sensor with TM1637 LED display with Arduino  
 *  This example shows how to use continuous mode to take

This is Arduino code to measure distance with VL53L0X and display it on TM1637 LED 7 Segment Display

Watch full video instruction: https://youtu.be/OtU7WRun6dU

  
  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/>.
	
Original Laser Sensor source source: https://github.com/adafruit/Adafruit_VL53L0X
Modefied by Ahmad Shamshiri for RoboJax.com
Date modefied: May 31, 2018 at 19:25 at Ajax, Ontario, Canada

Pin connection

VL53L0X Pin  Arduino Pin
VCC         5V
GND         GND
SDA         A4 or SDA if available
SCL         A5 or SCL if available
GPIO1       leave it unconnected
XSHUT       D12 (digital 12 or pin 12)
*/


#include <Wire.h>
#include <VL53L0X.h>
VL53L0X sensor;
int VCC2= 13;// 2nd VCC for laser sensor

/////// start of TM1637 Display
#include <Arduino.h>
#include <TM1637Display.h> 
#define CLK 5
#define DIO 6
#define TEST_DELAY   500
TM1637Display display(CLK, DIO);
uint8_t clearLED[] = { 0x0, 0x0, 0x0, 0x0 }; // value for clearing the LEDs
////// End of TM1637 Display 


void setup()
{

  Serial.begin(9600);
  pinMode(VCC2, OUTPUT);// set pin 13 HIGH for extra 5V
  digitalWrite(VCC2, HIGH);// make pin 13 HIGH so we have extra 5V
    
  Wire.begin();// I2C communication initialized

  sensor.init();// distance sensor is initialized
  sensor.setTimeout(500); // time out is set

  // Start continuous back-to-back mode (take readings as
  // fast as possible).  To use continuous timed mode
  // instead, provide a desired inter-measurement period in
  // ms (e.g. sensor.startContinuous(100)).
  sensor.startContinuous();// type of measurement is set
    Serial.println("VL53L0X with TM1637 test");
    delay(500);
    display.setBrightness(0x0f);// set brightness for display
}

void loop()
{
  int distance =sensor.readRangeContinuousMillimeters();// read the distance in mm
  display.setSegments(clearLED);// remove previous value from LED display
  display.showNumberDec(distance, false, 4, 0);// display the distance

  
 //distance = distance;
  Serial.print("Distance: ");
  Serial.print(distance);// print distance on serial monitor
  Serial.print("mm");
  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }

  Serial.println();
  delay(100);
} 

   

The least I expect from you is to thumb up the video and subscribe to my channel. I appriciate that. .I have spent months making these lectures and writing code. You don't lose anything by subscribging to my channel. Your subscription is stamp of approval to my videos and more people can find them and in it turn it helps me. Thank you

If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal

**** AFFILIATE PROGRAM **** We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.

Right Side
footer