I have included 5 examples with a wiring diagram and code so you can start experimenting with your sensor. We will first look at an example that does not use an Arduino library. Next, I will show you how you can use theNewPinglibrary to create a more compact code. Cheap ultrasonic dist...
High);//Laser rangefinder begins to worksensor.start();}voidloop(){//Get the distanceSerial.print("Distance: ");Serial.println(sensor.getDistance());//The delay is added to demonstrate the
//--- // Example NewPing library sketch that does a ping about 20 times per second //--- //initialize the library code #include <Wire.h> #include <LiquidCrystal_I2C.h> #include <NewPing.h> LiquidCrystal_I2C lcd(0x27, 16, 2); #define TRIGGER_PIN 2 // Arduino pin tied to the...
//Sensor does not respond within the timeout time Serial.println("VL53L0X is not responding, check your wiring"); } else { //SET THE SENSOR TO LONG RANGE MODE // lower the return signal rate limit (default is 0.25 MCPS) sensor.setSignalRateLimit(0.1); // increase laser pulse periods...
VL53L0X sensor; //Create the sensor object int startTime = millis(); //used for our timing loop int mInterval = 100; //refresh rate of 10hz void setup() { Serial.begin(57600); Wire.begin(); //Setup your I2C interface Wire.setClock(400000); // use 400 kHz I2C ...
#define ECHO_PIN 3 // Arduino pin tied to echo pin on the ultrasonic sensor. #define MAX_DISTANCE 400 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pin...
If your board doesn't come with CircuitPython running on it already then check out your board's guide for how to load CircuitPython firmware. For example the Feather M0 express guide is a good reference. VL6180X time-of-flight distance sensor. This is a handy sensor that uses a laser to...
Infrared Laser Distance Sensor(50m/80m) x1 Wires Software Arduino IDE Connection Diagram Sample Code SEN0366 Communication Protocol.pdf /*! * @File DFRobot_IraserSensor.ino * @brief In this example, the infrared laser ranging sensor is used to measure the distance, and the sensor data is pro...
/** HC-SR04 example sketch** Getting Started with the HC-SR04 Ultrasonic sensor** by Isaac100*/constinttrigPin=9;constintechoPin=10;floatduration,distance;voidsetup(){pinMode(trigPin,OUTPUT);pinMode(echoPin,INPUT);Serial.begin(9600);}voidloop(){digitalWrite(trigPin,LOW);delayMicroseconds(2)...
* This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-ultrasonic-sensor */ #define TRIG_PIN 9 // TRIG pin #define ECHO_PIN 8 // ECHO pin float filterArray[20]; // array to store data samples from sensor ...