Created
April 11, 2017 08:55
-
-
Save show0k/3883583ccf8ae215a51008b61e9ffd8f to your computer and use it in GitHub Desktop.
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
/* This example shows how to use continuous mode to take | |
range measurements with the VL53L0X. It is based on | |
vl53l0x_ContinuousRanging_Example.c from the VL53L0X API. | |
The range readings are in units of mm. */ | |
// | |
#include <Wire.h> | |
#include <VL53L0X.h> | |
#include <ArduinoJson.h> | |
VL53L0X sensor; | |
StaticJsonBuffer<200> jsonBuffer; | |
JsonObject& json = jsonBuffer.createObject(); | |
void setup() | |
{ | |
//Serial.begin(1000000); | |
//Serial.begin(9600); | |
Serial.begin(1000000); | |
Wire.begin(); | |
sensor.init(); | |
sensor.setTimeout(500); | |
// 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(); | |
} | |
void loop() | |
{ | |
/*Serial.print(sensor.readRangeContinuousMillimeters()); | |
if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }*/ | |
json["distance"] = sensor.readRangeContinuousMillimeters(); | |
json.printTo(Serial); | |
delay(0.02); | |
Serial.println(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment