13浏览
查看: 13|回复: 4

[项目] 【Arduino 动手做】带有 2xHC-SR04 传感器的 360° Arduino 雷达

[复制链接]
超声波传感器模块安装在旋转 0 至 180° 之间的伺服电机上,在这种情况下,有趣的是使用两个传感器来扫描整个 360 度空间。

这次我将向您展示如何制作基于 Arduino 的超声波雷达。我们可以称之为声纳,因为它利用的是声音,但声纳通常被认为是在水下使用的。在本例中,有趣的是,我们使用两个传感器来扫描整个 360 度空间。超声波传感器模块安装在一个可在 0 到 180° 之间旋转的伺服电机上。这种方法也简化了设计,因为您不会遇到电缆缠绕在伺服电机上的问题。

【Arduino 动手做】带有 2xHC-SR04 传感器的 360° Arduino 雷达图1

驴友花雕  中级技神
 楼主|

发表于 3 小时前

【Arduino 动手做】带有 2xHC-SR04 传感器的 360° Arduino 雷达

前往https://bit.ly/3DQGHBn制作您的 PCB。新用户可享 50 美元优惠券。

该过程从测试伺服器旋转开始。首先,它旋转 0° 到 180°,然后旋转 180° 到 0°,以检查耳机是否正确移动。该过程从测试伺服器旋转开始。首先,它旋转 0° 到 180°,然后旋转 180° 到 0°,以检查耳机是否正确移动。该过程从测试伺服器旋转开始。首先,它旋转 0° 到 180°,然后旋转 180° 到 0°,以检查耳机是否正确移动。

   该设备构建起来非常简单,由以下几个元素组成:
     - Arduino Nano 微控制器
     - 小型 9g 伺服电机
     - 和两个 HC-SR04 超声波模块

【Arduino 动手做】带有 2xHC-SR04 传感器的 360° Arduino 雷达图1

【Arduino 动手做】带有 2xHC-SR04 传感器的 360° Arduino 雷达图3

【Arduino 动手做】带有 2xHC-SR04 传感器的 360° Arduino 雷达图2

回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 3 小时前

【Arduino 动手做】带有 2xHC-SR04 传感器的 360° Arduino 雷达

启动时,测试伺服电机的运动。此后,雷达立即开始扫描。接下来,我们在 PC 上启动 Processing 应用程序,然后需要输入与 Arduino 通信的正确串行端口。这样就会显示一个类似雷达的监视器,上面正在监视对象。需要说明的是,这个想法和代码是西班牙电子工程专业学生 Victor Casado 的作品。从图片中可以看到,该设备还包含一个压电蜂鸣器。这是因为我目前正在测试修改后的代码,根据物体的距离,发出具有特定频率的声音。如果成功,我将以更新的形式发布新代码。
  1. #include <HCSR04.h>
  2. #include <Servo.h>
  3. UltraSonicDistanceSensor distanceSensor(6, 7);             //Create the 1st sensor object
  4. UltraSonicDistanceSensor distanceSensor2(5, 4);             //Create the 2nd sensor object
  5. Servo servoMotor;            //Create the Servo object
  6. int delayTime = 5;            //Delay value to wait for the servo to reach the 1 angle difference
  7. long d;                 //Distance from 1st sensor calculated
  8. long d2;                //Distance from 2nd sensor calculated
  9. void setup() {
  10.   Serial.begin(9600);           //Initialize the Serial communication at 9600 bauds
  11.   servoMotor.attach(2);         //Attach the servo to the Digital PWM pin 2
  12.   servoMotor.write(180);        //Rotate the servo to the 180?
  13.   delay(1000);              //Wait for the servo to reach 180?
  14.   servoMotor.write(0);          //Rotate the servo to the 0?
  15.   delay(1000);              //Wait for the servo to reach 0?
  16. }
  17. void loop() {
  18.   for (int i = 1; i < 180; i++) {   //Move the Servo 180 degrees forward
  19.     readSensors();            //Read the sensors
  20.     Serial.print(i);          //Print the angle
  21.     Serial.print(",");          //Print a ","
  22.     Serial.print(d);          //Print the 1st distance
  23.     Serial.print(",");          //Print a ","
  24.     Serial.println(d2);         //Print the 2nd distance with end line
  25.     servoMotor.write(i);        //Set the sensor at the angle
  26.     delay(delayTime);         //Wait for the servo to reach i?
  27.   }
  28.   for (int i = 180; i > 1; i--) {   //Move the Servo 180 degrees backward
  29.     readSensors();            //Read the sensors
  30.     Serial.print(i);          //Print the angle
  31.     Serial.print(",");          //Print a ","
  32.     Serial.print(d);          //Print the 1st distance
  33.     Serial.print(",");          //Print a ","
  34.     Serial.println(d2);         //Print the 2nd distance with end line
  35.     servoMotor.write(i);        //Set the sensor at the angle
  36.     delay(delayTime);         //Wait for the servo to reach i?
  37.   }
  38. }
  39. void readSensors() {
  40.   d = distanceSensor.measureDistanceCm();
  41.   d2 = distanceSensor2.measureDistanceCm();
  42. }
复制代码




回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 3 小时前

【Arduino 动手做】带有 2xHC-SR04 传感器的 360° Arduino 雷达

最后,将该装置装入一个合适的盒子中,该盒子由厚度为 3 毫米和 5 毫米的 PVC 板制成,并涂有自粘彩色壁纸。

【Arduino 动手做】带有 2xHC-SR04 传感器的 360° Arduino 雷达图1
回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 3 小时前

【Arduino 动手做】带有 2xHC-SR04 传感器的 360° Arduino 雷达

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4 备案 沪公网安备31011502402448

© 2013-2025 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail