Daftar Isi:

: 4 Langkah
: 4 Langkah

Video: : 4 Langkah

Video: : 4 Langkah
Video: KOMEDI FUL SELINGKUH 4 LANGKAH - MADURA LUCU 2024, November
Anonim
聲納
聲納

:https://aboutsciences.com/blog/arduino-radar-using…

我 在 原本 聲納 的 基礎 下 加裝 了 喇叭 以 達到 警告 的 作用

: arduino uno,,,:掃描到物品時加速並傳述到電腦,物品接近10cm時喇叭會警告

Langkah 1: Langkah 1

Langkah 1
Langkah 1

這 是 電路圖

Langkah 2: Langkah 2 (arduino)

Langkah 2 (arduino)
Langkah 2 (arduino)

create.arduino.cc/editor/dwdawdad/ef6b26a2-3f40-410d-9fdd-3413816090fe/preview

Langkah 3: Langkah 3 (pemrosesan)

import processing.serial.*;

impor java.awt.event. KeyEvent; impor java.io. IOException;

Port saya serial; PFont orcFont; int sudut; int jarak; void setup() { ukuran(1000, 500); halus(); myPort = Serial baru(ini, "COM7", 9600); myPort.clear(); myPort.bufferSampai('\n');

} batal draw() { isi(98, 245, 31); tidak ada Stroke(); isi(0, 4); rect(0, 0, lebar, 0,935 * tinggi); isi(98, 245, 31); DrawRadar(); DrawLine(); DrawObject(); DrawTeks(); } void serialEvent (Serial myPort) { try { String data = myPort.readStringUntil('\n'); if (data == null) { kembali; } int commaIndex = data.indexOf(", "); Sudut string = data.substring(0, commaIndex); Jarak string = data.substring(commaIndex+1, data.length()-1); iAngle = StringToInt(sudut); iDistance = StringToInt(jarak); } catch(RuntimeException e) {} } void DrawRadar() { pushMatrix(); terjemahkan (lebar/2, 0,926 * tinggi); tidak ada Isi(); strokeBerat (2); pukulan (98, 245, 31); // menggambar garis busur DrawRadarArcLine(0.9375); DrawRadarArcLine(0.7300); DrawRadarArcLine(0.5210); DrawRadarArcLine(0.3130); // menggambar garis sudut final int halfWidth = width/2; line(-halfWidth, 0, halfWidth, 0); for(int sudut = 30; sudut <= 150; sudut+=30) { DrawRadarAngledLine(sudut); } garis(-lebar setengah * cos(radian(30)), 0, lebar setengah, 0); popMatriks(); } void DrawRadarArcLine(koefisien float akhir) { arc(0, 0, koefisien * lebar, koefisien * lebar, PI, TWO_PI); } void DrawRadarAngledLine(sudut int akhir){ line(0, 0, (-lebar/2) * cos(radian(sudut)), (-lebar/2) * sin(radian(sudut))); } void DrawObject() { pushMatrix(); terjemahkan (lebar/2, 0,926 * tinggi); strokeBerat (9); pukulan (255, 10, 10); int pixsJarak = int(iDistance * 0.020835 * tinggi); if(iDistance 40 ? "Out of Range": "In Range"), 0,125 * lebar, 0,9723 * tinggi); text("Sudut: " + iAngle + " °", 0,52 * lebar, 0,9723 * tinggi); text("Jarak: ", 0,74 * lebar, 0,9723 * tinggi); if(iDistance < 40) { teks(" " + iDistance +" cm", 0,775 * lebar, 0,9723 * tinggi); } ukuran teks(25); isi(98, 245, 60); translate(0.5006 * lebar + lebar/2 * cos(radian(30)), 0.9093 * tinggi - lebar/2 * sin(radian(30))); memutar(-radian(-60)); teks("30°", 0, 0); resetMatrix(); translate(0.497 * lebar + lebar/2 * cos(radian(60)), 0,9112 * tinggi - lebar/2 * sin(radian(60))); memutar(-radian(-30)); teks("60 °", 0, 0); resetMatriks(); translate(0.493 * lebar + lebar/2 * cos(radian(90)), 0.9167 * tinggi - lebar/2 * sin(radian(90))); putar(radian(0)); teks("90°", 0, 0); resetMatrix(); translate(0.487 * lebar + lebar/2 * cos(radian(120)), 0.92871 * tinggi - lebar/2 * sin(radian(120))); putar(radian(-30)); teks("120°", 0, 0); resetMatrix(); translate(0.4896 * lebar + lebar/2 * cos(radian(150)), 0.9426 * tinggi - lebar/2 * sin(radian(150))); memutar (radian (-60)); teks("150°", 0, 0); popMatriks(); }

int StringToInt(String string) { int nilai = 0; for(int i = 0; i = '0' && string.charAt(i) <= '9') { nilai *= 10; nilai += (string.charAt(i) - '0'); }} mengembalikan nilai;}

Direkomendasikan: