Mundarija:

聲納: 4 qadam
聲納: 4 qadam

Video: 聲納: 4 qadam

Video: 聲納: 4 qadam
Video: Диагностика гбо 4 поколения своими руками 2024, Noyabr
Anonim
Y
Y

改作:

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

Ma'lumotlar: arduino uno, qarang, yun, s

功能: 到 到 物品 時 時 傳 傳 接近 接近 接近 接近 接近 接近 cm cm 10 sm.

1 -qadam: 1 -qadam

1 -qadam
1 -qadam

這 是 電路圖

2 -qadam: 2 -qadam (arduino)

2 -qadam (arduino)
2 -qadam (arduino)

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

3 -qadam: 3 -qadam (ishlov berish)

importni qayta ishlash.serial.*;

java.awt.event. KeyEvent -ni import qilish; java.io. IOException ni import qilish;

Seriyali myPort; PFont orcFont; int iAngle; int iDistance; void setup () {size (1000, 500); silliq (); myPort = yangi seriyali (bu, "COM7", 9600); myPort.clear (); myPort.bufferUntil ('\ n');

} void draw () {fill (98, 245, 31); noStroke (); to'ldirish (0, 4); to'g'ri (0, 0, kenglik, 0,935 * balandlik); to'ldirish (98, 245, 31); DrawRadar (); DrawLine (); DrawObject (); DrawText (); } void serialEvent (Serial myPort) {harakat qilib ko'ring {String data = myPort.readStringUntil ('\ n'); if (ma'lumotlar == null) {qaytish; } int commaIndex = data.indexOf (","); String burchagi = data.substring (0, commaIndex); String masofasi = data.substring (commaIndex+1, data.length ()-1); iAngle = StringToInt (burchak); iDistance = StringToInt (masofa); } catch (RuntimeException e) {}} DrawRadar () {pushMatrix (); tarjima qilish (kenglik/2, 0,926 * balandlik); noFill (); strokeWeight (2); qon tomir (98, 245, 31); // DrawRadarArcLine (0,9375) yoy chiziqlarini chizadi; DrawRadarArcLine (0,7300); DrawRadarArcLine (0.5210); DrawRadarArcLine (0.3130); // burchak chiziqlarini chizadi final int halfWidth = width/2; chiziq (-halfWidth, 0, halfWidth, 0); uchun (int burchagi = 30; burchak <= 150; burchak+= 30) {DrawRadarAngledLine (burchak); } chiziq (-halfWidth * cos (radian (30)), 0, halfWidth, 0); popMatrix (); } void DrawRadarArcLine (oxirgi suzish koeffitsienti) {yoy (0, 0, koeffitsient * kenglik, koeffitsient * kenglik, PI, TWO_PI); } void DrawRadarAngledLine (yakuniy int burchagi) {chiziq (0, 0, (-kenglik/2) * cos (radian (burchak)), (-kenglik/2) * sin (radian (burchak))); } bekor DrawObject () {pushMatrix (); tarjima qilish (kenglik/2, 0,926 * balandlik); strokeWeight (9); qon tomir (255, 10, 10); int pixsDistance = int (iDistance * 0.020835 * balandligi); if (iDistance 40? "Diapazondan tashqarida": "Diapazonda"), 0,125 * kenglik, 0,9723 * balandlik); matn ("Burchak:" + iAngle + "°", 0,52 * kenglik, 0,9723 * balandlik); matn ("Masofa:", 0,74 * kenglik, 0,9723 * balandlik); if (iDistance <40) {matn ("" + iDistance + "sm", 0,775 * kenglik, 0,9723 * balandlik); } textSize (25); to'ldirish (98, 245, 60); tarjima qilish (0,5006 * kenglik + kenglik/2 * cos (radianlar (30)), 0,9093 * balandlik - kenglik/2 * sin (radianlar (30))); aylantirish (-radianlar (-60)); matn ("30 °", 0, 0); resetMatrix (); tarjima qilish (0,497 * kenglik + kenglik/2 * cos (radianlar (60)), 0,9112 * balandlik - kenglik/2 * sin (radianlar (60))); aylantirish (-radianlar (-30)); matn ("60 °", 0, 0); resetMatrix (); tarjima qilish (0,493 * kenglik + kenglik/2 * cos (radianlar (90)), 0,9167 * balandlik - kenglik/2 * sin (radianlar (90))); aylantirish (radianlar (0)); matn ("90 °", 0, 0); resetMatrix (); tarjima qilish (0,487 * kenglik + kenglik/2 * cos (radianlar (120)), 0,92871 * balandlik - kenglik/2 * sin (radianlar (120))); aylantirish (radianlar (-30)); matn ("120 °", 0, 0); resetMatrix (); tarjima qilish (0,4896 * kenglik + kenglik/2 * cos (radianlar (150)), 0,9426 * balandlik - kenglik/2 * sin (radianlar (150))); aylantirish (radianlar (-60)); matn ("150 °", 0, 0); popMatrix (); }

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

Tavsiya: