Outils pour utilisateurs

Outils du site


start:arduino:vl53lxxv2

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
start:arduino:vl53lxxv2 [2024/03/25 10:47] – [Programme Arduino/ESP32 pour distance sensor VL53L1X] gerardadminstart:arduino:vl53lxxv2 [2024/03/25 11:04] (Version actuelle) – [code Robot Tourne] gerardadmin
Ligne 106: Ligne 106:
 </code> </code>
  
 +== code Robot Tourne ==
 +
 +<code c Robottourne.ino>
 +#include "Adafruit_VL53L0X.h"
 +
 +Adafruit_VL53L0X lox = Adafruit_VL53L0X();
 +int distanceR = 0;
 +void setup()
 +{
 +Serial.begin(115200);
 +
 +// wait until serial port opens for native USB devices
 +while (! Serial)
 +{
 +delay(1);
 +}
 +
 +Serial.println("Adafruit VL53L0X test");
 +if (!lox.begin())
 +{
 +Serial.println(F("Failed to boot VL53L0X"));
 +while(1);
 +}
 +// power
 +Serial.println(F("VL53L0X API Simple Ranging example\n\n"));
 +}
 +void deplacementRobot()// exemple pour test
 +//Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
 +
 +{
 +if ( distanceR >= 200)
 +{ Serial.println("robotavance...>= 200");}
 +if  ( distanceR <=40)
 +{ Serial.println(" robotTourneDroite...<=40 ");}
 +}
 +
 +
 +void loop()
 +{
 +VL53L0X_RangingMeasurementData_t measure;
 +
 +//Serial.print("Reading a measurement... ");
 +lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!
 +
 +if (measure.RangeStatus != 4)
 +{ // phase failures have incorrect data
 +distanceR = measure.RangeMilliMeter;
 +//Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
 +deplacementRobot();
 +}
 +else
 +{
 +//Serial.println(" out of range ");
 +}
 +
 +delay(100);
 +}
 +</code>
  
  
  
  
/home/chanteri/www/fablab37110/data/attic/start/arduino/vl53lxxv2.1711360061.txt.gz · Dernière modification : 2024/03/25 10:47 de gerardadmin