start:arduino:vl53lxxv2
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
start:arduino:vl53lxxv2 [2024/03/24 11:41] – [Caractéristiques VL53L1X, VL53LOX Arduino:] gerardadmin | start:arduino:vl53lxxv2 [2024/03/25 11:04] (Version actuelle) – [code Robot Tourne] gerardadmin | ||
---|---|---|---|
Ligne 40: | Ligne 40: | ||
- | ====Comment brancher distance | + | ====Comment brancher |
- | ^VL53LOX / VL53L1X^ Arduino Uno^ Arduino Nano^ Arduino Mega^ | + | ^VL53LOX / VL53L1X^ Arduino Uno^ Arduino Nano^ Arduino Mega^ ESP32^ |
- | |GND |GND |GND |GND | | + | |GND |GND |GND |GND | GND | |
- | |VDD |5V |5V |5V | | + | |VDD |5V |5V |5V | 5V | |
- | |SDA |A4 |A4 |20 | | + | |SDA |A4 |A4 |20 |
- | |SCL |A5 |A5 |21 | | + | |SCL |A5 |A5 |21 |
- | le premier | + | Cet exemple affiche régulièrement la distance mesurée (en millimètres) dans le moniteur série de l’IDE Arduino. Le programme s’exécute en arrière-plan en utilisant les bibliothèques Wire et VL53L1X, le programme initial est donc très court. Connectez le capteur de distance laser au microcontrôleur Arduino Uno comme indiqué dans le schéma ci-dessus et chargez le code pour distance sensor VL53L0X / GY-53-L1X. |
{{ : | {{ : | ||
- | ====Programme Arduino pour distance sensor VL53L1X==== | + | ====Programme Arduino/ |
- | <code c vl53LxXV2.ino> | + | ==Bibliotheque Adafruit_VL53L0X== |
- | #include " | + | |
- | #include " | + | |
- | SFEVL53L1X vl; | + | |
- | void setup () { | + | [[https:// |
- | Serial.begin(9600); | + | |
- | vl.setOffset(0); | + | |
- | // vl.setDistanceModeShort(); | ||
- | // vl.setROI(4, | ||
- | } | ||
- | |||
- | void loop() { | ||
- | vl.startRanging(); | ||
- | while (!vl.checkForDataReady()) { delay(1); } | ||
- | int dist = vl.getDistance(); | ||
- | vl.stopRanging(); | ||
- | |||
- | Serial.print(" | ||
- | Serial.print(dist); | ||
- | Serial.println(" | ||
- | |||
- | delay(1000); | ||
- | } | ||
- | </ | ||
- | ==== Pour ESP32 ==== | ||
<code c vl53lx002.ino> | <code c vl53lx002.ino> | ||
Ligne 129: | Ligne 106: | ||
</ | </ | ||
+ | == code Robot Tourne == | ||
+ | |||
+ | <code c Robottourne.ino> | ||
+ | #include " | ||
+ | |||
+ | 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(" | ||
+ | if (!lox.begin()) | ||
+ | { | ||
+ | Serial.println(F(" | ||
+ | while(1); | ||
+ | } | ||
+ | // power | ||
+ | Serial.println(F(" | ||
+ | } | ||
+ | void deplacementRobot()// | ||
+ | // | ||
+ | |||
+ | { | ||
+ | if ( distanceR >= 200) | ||
+ | { Serial.println(" | ||
+ | if ( distanceR <=40) | ||
+ | { Serial.println(" | ||
+ | } | ||
+ | |||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | VL53L0X_RangingMeasurementData_t measure; | ||
+ | |||
+ | // | ||
+ | lox.rangingTest(& | ||
+ | |||
+ | if (measure.RangeStatus != 4) | ||
+ | { // phase failures have incorrect data | ||
+ | distanceR = measure.RangeMilliMeter; | ||
+ | // | ||
+ | deplacementRobot(); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | // | ||
+ | } | ||
+ | |||
+ | delay(100); | ||
+ | } | ||
+ | </ | ||
/home/chanteri/www/fablab37110/data/attic/start/arduino/vl53lxxv2.1711276905.txt.gz · Dernière modification : 2024/03/24 11:41 de gerardadmin