Cov txheej txheem:

聲納: 4 Cov kauj ruam
聲納: 4 Cov kauj ruam

Video: 聲納: 4 Cov kauj ruam

Video: 聲納: 4 Cov kauj ruam
Video: Nkauj Hnub Leej Tub (Hmong Dubbed) 2024, Kaum ib hlis
Anonim
聲納
聲納

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

我 在 原本 聲納 的 基礎 下 加裝 了 了 喇叭 喇叭 喇叭 喇叭 喇叭

材料: arduino uno, 感測器 感測器, 驅動 馬達, 喇叭

功能: 到 到 物品 加速 傳 述 到 電腦 cm cm cm cm cm cm 10cm 喇叭 喇叭

Kauj Ruam 1: Kauj Ruam 1 電路圖

Kauj Ruam 1 電路圖
Kauj Ruam 1 電路圖

這 是 電路圖

Kauj Ruam 2: Kauj Ruam 2 程式 程式 (arduino)

Kauj ruam 2 程式 程式 (arduino)
Kauj ruam 2 程式 程式 (arduino)

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

Kauj Ruam 3: Kauj Ruam 3 程式 程式 (ua tiav)

ntshuam ua.serial.*;

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

Serial myPort; PFont orcFont; koj iAngle; koj iDistance; teeb tsa tsis muaj dab tsi () {qhov loj me (1000, 500); tus (); myPort = Serial tshiab (qhov no, "COM7", 9600); myPort.clear (); myPort.bufferUntil ('\ n');

} void kos () {sau (98, 245, 31); noStroke (); sau (0, 4); rect (0, 0, dav, 0.935 * qhov siab); sau (98, 245, 31); DrawRadar (); DrawLine (); DrawObject (); DrawText (); } void serialEvent (Serial myPort) {sim {String data = myPort.readStringUntil ('\ n'); yog (data == null) {rov qab; } int commaIndex = data.indexOf (","); Txoj hlua txoj kab = data.substring (0, commaIndex); Txoj hlua nrug = data.substring (commaIndex+1, data.length ()-1); iAngle = StringToInt (lub kaum ntse ntse); iDistance = StringToInt (nrug); } ntes (RuntimeException e) {}} tsis muaj dab tsi DrawRadar () {pushMatrix (); txhais lus (dav/2, 0.926 * qhov siab); noFill (); strokeWeight (2); mob stroke (98, 245, 31); // thim cov kab kos DrawRadarArcLine (0.9375); DrawRadarArcLine (0.7300); DrawRadarArcLine (0.5210); DrawRadarArcLine (0.3130); // thim lub kaum kab kab kawg int ib nrabWidth = dav/2; kab (-halfWidth, 0, halfWidth, 0); rau (int kaum = 30; kaum sab xis = 150; kaum sab xis+= 30) {DrawRadarAngledLine (kaum sab xis); } kab (-halfWidth * cos (radians (30)), 0, halfWidth, 0); popMatrix (); } tsis muaj dab tsi DrawRadarArcLine (zaum kawg coefficient) {arc (0, 0, coefficient * dav, coefficient * dav, PI, TWO_PI); } tsis muaj dab tsi DrawRadarAngledLine (kawg lub kaum ntse ntse) {kab (0, 0, (-width/2) * cos (radians (lub kaum sab xis)), (-width/2) * sin (radians (angle)))); } tsis muaj dabtsis DrawObject () {pushMatrix (); txhais lus (dav/2, 0.926 * qhov siab); Qhov hnyav (9); mob stroke (255, 10, 10); int pixsDistance = int (iDistance * 0.020835 * qhov siab); yog (iDistance 40? ntawv ("Lub:" + iAngle + "°", 0.52 * dav, 0.9723 * qhov siab); ntawv ("Nrug:", 0.74 * dav, 0.9723 * qhov siab); yog (iDistance <40) {text ("" + iDistance + "cm", 0.775 * dav, 0.9723 * qhov siab); } textSize (25); sau (98, 245, 60); txhais (0.5006 * dav + dav/2 * cos (radians (30)), 0.9093 * qhov siab - dav/2 * sin (radians (30)))); tig (-radians (-60)); ntawv ("30 °", 0, 0); resetMatrix (); txhais (0.497 * dav + dav/2 * cos (radians (60)), 0.9112 * qhov siab - dav/2 * sin (radians (60))); tig (-radians (-30)); ntawv ("60 °", 0, 0); resetMatrix (); txhais (0.493 * dav + dav/2 * cos (radians (90)), 0.9167 * qhov siab - dav/2 * sin (radians (90)))); tig (radians (0)); ntawv ("90 °", 0, 0); resetMatrix (); txhais (0.487 * dav + dav/2 * cos (radians (120)), 0.92871 * qhov siab - dav/2 * sin (radians (120))); tig (radians (-30))); ntawv ("120 °", 0, 0); resetMatrix (); txhais (0.4896 * dav + dav/2 * cos (radians (150)), 0.9426 * qhov siab - dav/2 * sin (radians (150)))); tig (radians (-60)); ntawv ("150 °", 0, 0); popMatrix (); }

int StringToInt (Txoj hlua hlua) {int tus nqi = 0; rau (int i = 0; i = '0' && string.charAt (i) <= '9') {value *= 10; tus nqi += (hlua.charAt (i) - '0'); }} rov qab tus nqi;}

Pom zoo: