Radar z lidar sensor

 

Radar z lidar sensor



1. Zainstaluj "LIDARLite Arduino Library" i "Servo Arduino Library" w swoim Arduino IDE, przechodząc do Sketch->Include library->Dodaj bibliotekę z pliku ZIP.

2. Prześlij szkic Arduino na swoją tablicę.

3. Połącz wszystkie komponenty zgodnie z załączonymi schematami.

4. Włącz Arduino i uruchom dołączony pakiet Power-KI.


https://www.youtube.com/watch?v=Vm3c8mJqvCs

https://www.youtube.com/watch?v=EU-jh4T8-zM



#include <Servo.h> #include <Wire.h> #include <LIDARLite.h> unsigned short crv[3]; #define HEADSAM 0xFAFB #define CRV_HEAD crv[0] #define CRV_ANGL crv[1] #define CRV_DIST crv[2] byte* buff; #define SERVO_PIN 9 Servo myservo; int pos = 0; bool servoAlive = true; LIDARLite lidarLite; int cal_cnt = 0; void setup() { Serial.begin(9600); myservo.attach(SERVO_PIN); myservo.write(0); CRV_HEAD = HEADSAM; buff= (byte*) crv; lidarLite.begin(0, true); lidarLite.configure(0); } int readLidar() { int dist; if ( cal_cnt == 0 ) { dist = lidarLite.distance(); } else { dist = lidarLite.distance(false); } cal_cnt++; cal_cnt = cal_cnt % 100; return dist; } void loop() { if(servoAlive){ if (pos >= 180) { pos = 0; } else { pos++; } myservo.write(pos); } delay(15); CRV_ANGL = pos; CRV_DIST = readLidar(); Serial.write(buff, 10); if (Serial.available() > 0) { int incomingByte = Serial.read(); if(incomingByte == 0) { servoAlive = false; } if(incomingByte == 1) { servoAlive = true; } } }
Okablowanie

diagram







































Komentarze