Other Arduino Codes and Videos by Robojax

Measure Distance with Laser VL53L0X 6 pin module and TM1637 Display for Arduino

دروس آردوینو به فارسی

Measure Distance with Laser VL53L0X 6 pin module with TM1637 LED Display for Arduino

This code is to measure distance using laser module ToF Time of Flight VL53L0X 6 pin module and TM1637 LED display. This module is sold on eBay or AliExpress in different color but mostly (as of Jun 2018) sold in pink color.

VL53L0X Dimensions

Dimensions

VL53L0X Dimensions 2

Dimensions 2

VL53L0X Emitter and Collector cone angles

VL53L0X Emitter and Collector cone angles

  /* 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

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
You have to watch 1 Video before using this code:
1- Watch VL53L0X Video and get code https://youtu.be/1n9eJ9HaYpE
2- Watch TM1637 Video and get code http://robojax.com/learn/arduino/?vid=robojax-TM1637
You can get this code from Robojax.com

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;

/////// start of TM1637 Display
#include <Arduino.h>
#include <TM1637Display.h> 
#define CLK 2
#define DIO 3
#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()
{
  pinMode(12,INPUT_PULLUP);// set pin 12 for input
  digitalWrite(12,HIGH);// set pin 12 high (5V)
  Serial.begin(9600);
  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 MAX6675 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);
}   

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