Created
August 2, 2020 15:04
-
-
Save myarduinosale/b07c086be4b78abdca1657d032552218 to your computer and use it in GitHub Desktop.
M0765_ESP32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <VL53L0X.h> | |
int led = 18; | |
int buzzer = 19; | |
VL53L0X sensor; | |
void setup() | |
{ | |
Serial.begin(9600); | |
Wire.begin(); | |
pinMode (led, OUTPUT); | |
pinMode (buzzer, OUTPUT); | |
sensor.init(); | |
sensor.setTimeout(500); | |
sensor.startContinuous(); | |
} | |
void loop() { | |
Serial.print(sensor.readRangeContinuousMillimeters()); | |
if (sensor.timeoutOccurred()) { | |
Serial.print(" TIMEOUT"); | |
} | |
if (sensor.readRangeContinuousMillimeters()< 50) { | |
digitalWrite(led, HIGH); | |
digitalWrite(buzzer, LOW); | |
} | |
if (sensor.readRangeContinuousMillimeters()> 50) { | |
digitalWrite(led,LOW); | |
digitalWrite(buzzer, HIGH); | |
} | |
Serial.println(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment