一区二区三区三上|欧美在线视频五区|国产午夜无码在线观看视频|亚洲国产裸体网站|无码成年人影视|亚洲AV亚洲AV|成人开心激情五月|欧美性爱内射视频|超碰人人干人人上|一区二区无码三区亚洲人区久久精品

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

如何制作Arduino雷達(dá)

454398 ? 來(lái)源:wv ? 2019-08-28 11:06 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

第1步:材料和程序

此構(gòu)建所需的材料包括:

- 1個(gè)伺服

- 1個(gè)超聲波傳感器

- 1個(gè)蜂鳴器

- 1面包板

- 1 UNO R3 Arduino

- 電線堆

制作此雷達(dá)所需的程序:

- Arduino IDE

- 處理3.4

要將上述程序下載到您的計(jì)算機(jī)上,請(qǐng)點(diǎn)擊以下鏈接:

- https://www.arduino.cc/en/main/software

-https://processing.org/download/

第2步:Arduino代碼

這是arduino代碼,它基本上控制伺服和傳感器的運(yùn)動(dòng)和輸入。這是從youtube視頻https://www.youtube.com/watch?v=JvmIutmQd9U復(fù)制而來(lái),似乎與我的arduino板和計(jì)算機(jī)很好地配合。

// Includes the servo library

#include 。

// Defines Trig and Echo pins of the Ultrasonic Sensor

const int trigPin = 10;

const int echoPin = 11;

#define buzzerPin A0 //Defines the pin A0 as an output to buzzerPin

// Variables for the duration and the distance

long duration;

int distance;

Servo myServo; // Creates a servo object for controlling the servo motor

void setup() {

pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin, INPUT); // Sets the echoPin as an Input

Serial.begin(9600);

myServo.attach(12); // Defines on which pin is the servo motor attached

}

void loop() {

// rotates the servo motor from 15 to 165 degrees

for(int i=15;i《=165;i++){

myServo.write(i);

delay(30);

distance = calculateDistance();// Calls a function for calculating the distance measured by the Ultrasonic sensor for each degree

Serial.print(i); // Sends the current degree into the Serial Port

Serial.print(“,”); // Sends addition character right next to the previous value needed later in the Processing IDE for indexing

Serial.print(distance); // Sends the distance value into the Serial Port

Serial.print(“?!保? // Sends addition character right next to the previous value needed later in the Processing IDE for indexing

tone(buzzerPin, 10000 / distance);

}

// Repeats the previous lines from 165 to 15 degrees

for(int i=165;i》15;i--){

myServo.write(i);

delay(30);

distance = calculateDistance();

Serial.print(i);

Serial.print(“,”);

Serial.print(distance);

Serial.print(“。”);

tone(buzzerPin, 10000 / distance); //Produces a different tone according to the distance the object is from the sensor

}

}

// Function for calculating the distance measured by the Ultrasonic sensor

int calculateDistance(){

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds

distance= duration*0.034/2;

return distance;

}

步驟3:處理代碼

以下是我用于處理程序從超聲波傳感器獲取信息的代碼,并將其轉(zhuǎn)換為它創(chuàng)建的顯示。這是我從視頻https://www.youtube.com/watch?v=JvmIutmQd9U復(fù)制的代碼,該代碼效果非常好,只需要進(jìn)行一些調(diào)整。

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px ‘Helvetica Neue’; color: #000000; -webkit-text-stroke: #000000}

p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px ‘Helvetica Neue’; color: #000000; -webkit-text-stroke: #000000; min-height: 12.0px}

span.s1 {font-kerning: none}

import processing.serial.*; // imports library for serial communication

import java.awt.event.KeyEvent; // imports library for reading the data from the serial port

import java.io.IOException;

Serial myPort; // defines Object Serial

// defubes variables

String angle=“”;

String distance=“”;

String data=“”;

String noObject;

float pixsDistance;

int iAngle, iDistance;

int index1=0;

int index2=0;

PFont orcFont;

void setup() {

size (1200, 700); // ***CHANGE THIS TO YOUR SCREEN RESOLUTION***

smooth();

myPort = new Serial(this,“/dev/cu.usbmodem143401”, 9600); // starts the serial communication

myPort.bufferUntil(‘?!? // reads the data from the serial port up to the character ‘。’. So actually it reads this: angle,distance.

}

void draw() {

fill(98,245,31);

// simulating motion blur and slow fade of the moving line

noStroke();

fill(0,4);

rect(0, 0, width, height-height*0.065);

fill(98,245,31); // green color

// calls the functions for drawing the radar

drawRadar();

drawLine();

drawObject();

drawText();

}

void serialEvent (Serial myPort) { // starts reading data from the Serial Port

// reads the data from the Serial Port up to the character ‘?!?and puts it into the String variable “data”。

data = myPort.readStringUntil(‘。’);

data = data.substring(0,data.length()-1);

index1 = data.indexOf(“,”); // find the character ‘,’ and puts it into the variable “index1”

angle= data.substring(0, index1); // read the data from position “0” to position of the variable index1 or thats the value of the angle the Arduino Board sent into the Serial Port

distance= data.substring(index1+1, data.length()); // read the data from position “index1” to the end of the data pr thats the value of the distance

// converts the String variables into Integer

iAngle = int(angle);

iDistance = int(distance);

}

void drawRadar() {

pushMatrix();

translate(width/2,height-height*0.074); // moves the starting coordinats to new location

noFill();

strokeWeight(2);

stroke(98,245,31);

// draws the arc lines

arc(0,0,(width-width*0.0625),(width-width*0.0625),PI,TWO_PI);

arc(0,0,(width-width*0.27),(width-width*0.27),PI,TWO_PI);

arc(0,0,(width-width*0.479),(width-width*0.479),PI,TWO_PI);

arc(0,0,(width-width*0.687),(width-width*0.687),PI,TWO_PI);

// draws the angle lines

line(-width/2,0,width/2,0);

line(0,0,(-width/2)*cos(radians(30)),(-width/2)*sin(radians(30)));

line(0,0,(-width/2)*cos(radians(60)),(-width/2)*sin(radians(60)));

line(0,0,(-width/2)*cos(radians(90)),(-width/2)*sin(radians(90)));

line(0,0,(-width/2)*cos(radians(120)),(-width/2)*sin(radians(120)));

line(0,0,(-width/2)*cos(radians(150)),(-width/2)*sin(radians(150)));

line((-width/2)*cos(radians(30)),0,width/2,0);

popMatrix();

}

void drawObject() {

pushMatrix();

translate(width/2,height-height*0.074); // moves the starting coordinats to new location

strokeWeight(9);

stroke(255,10,10); // red color

pixsDistance = iDistance*((height-height*0.1666)*0.025); // covers the distance from the sensor from cm to pixels

// limiting the range to 40 cms

if(iDistance《40){

// draws the object according to the angle and the distance

line(pixsDistance*cos(radians(iAngle)),-pixsDistance*sin(radians(iAngle)),(width-width*0.505)*cos(radians(iAngle)),-(width-width*0.505)*sin(radians(iAngle)));

}

popMatrix();

}

void drawLine() {

pushMatrix();

strokeWeight(9);

stroke(30,250,60);

translate(width/2,height-height*0.074); // moves the starting coordinats to new location

line(0,0,(height-height*0.12)*cos(radians(iAngle)),-(height-height*0.12)*sin(radians(iAngle))); // draws the line according to the angle

popMatrix();

}

void drawText() { // draws the texts on the screen

pushMatrix();

if(iDistance》40) {

noObject = “Out of Range”;

}

else {

noObject = “In Range”;

}

fill(0,0,0);

noStroke();

rect(0, height-height*0.0648, width, height);

fill(98,245,31);

textSize(25);

text(“10cm”,width-width*0.3854,height-height*0.0833);

text(“20cm”,width-width*0.281,height-height*0.0833);

text(“30cm”,width-width*0.177,height-height*0.0833);

text(“40cm”,width-width*0.0729,height-height*0.0833);

textSize(40);

text(“Ryan‘s Radar”, width-width*0.875, height-height*0.0277);

text(“Angle: ” + iAngle +“ °”, width-width*0.48, height-height*0.0277);

text(“Distance: ”, width-width*0.26, height-height*0.0277);

if(iDistance《40) {

text(“ ” + iDistance +“ cm”, width-width*0.225, height-height*0.0277);

}

textSize(25);

fill(98,245,60);

translate((width-width*0.4994)+width/2*cos(radians(30)),(height-height*0.0907)-width/2*sin(radians(30)));

rotate(-radians(-60));

text(“30°”,0,0);

resetMatrix();

translate((width-width*0.503)+width/2*cos(radians(60)),(height-height*0.0888)-width/2*sin(radians(60)));

rotate(-radians(-30));

text(“60°”,0,0);

resetMatrix();

translate((width-width*0.507)+width/2*cos(radians(90)),(height-height*0.0833)-width/2*sin(radians(90)));

rotate(radians(0));

text(“90°”,0,0);

resetMatrix();

translate(width-width*0.513+width/2*cos(radians(120)),(height-height*0.07129)-width/2*sin(radians(120)));

rotate(radians(-30));

text(“120°”,0,0);

resetMatrix();

translate((width-width*0.5104)+width/2*cos(radians(150)),(height-height*0.0574)-width/2*sin(radians(150)));

rotate(radians(-60));

text(“150°”,0,0);

popMatrix();

}

步驟4:超聲波傳感器支架

由于我對(duì)此項(xiàng)目的啟發(fā)并未包含任何類型的支架來(lái)固定超聲波傳感器在適當(dāng)?shù)奈恢?,我決定3D打印這個(gè)支架是一個(gè)好主意,讓完成的設(shè)計(jì)看起來(lái)更整潔,并使一切更容易組合。保持超聲波傳感器的部分最終相對(duì)緊密地安裝在超聲波傳感器周圍,在保持其就位方面做得很好。然而,在下面切出的用于伺服臂進(jìn)入的孔有點(diǎn)太大,所以我需要添加很多膠水來(lái)保持它的位置。但總的來(lái)說(shuō),它的效果非常好,并且設(shè)計(jì)看起來(lái)很漂亮。

第5步:激光切割盒設(shè)計(jì)

實(shí)施此框以使項(xiàng)目具有干凈和專業(yè)的外觀。它在隱藏所有電線和arduino板本身方面做得很好。為了創(chuàng)建實(shí)際的盒子設(shè)計(jì),我使用網(wǎng)站http://www.makercase.com/來(lái)獲得手指邊緣以將盒子的每一側(cè)連接在一起。這是一個(gè)非常有用的網(wǎng)站,因?yàn)樗?jié)省了我大量的時(shí)間,并且非常容易使用。從雷達(dá)的成品中可以看出,我在設(shè)計(jì)的側(cè)面和頂部切出了測(cè)量孔,以便允許項(xiàng)目的部分需要在外面。這包括用于伺服的孔,我從下面粘到盒子上,連接到超聲波傳感器,蜂鳴器,以及從計(jì)算機(jī)到arduino板本身。這是相當(dāng)大的(盒子里有很多空間),但至少它給你很大的工作空間,沒有任何東西是狹窄的。如果你自己做一個(gè)盒子設(shè)計(jì),你肯定可以做得更小,一切都會(huì)適合。

步驟6:接線構(gòu)造

根據(jù)arduino代碼,超聲波傳感器必須連接到引腳10 11.雖然和所有超聲波傳感器一樣,它也必須連接到地和5V引腳。伺服必須連接到引腳12(myServo.attach(12);),它還必須連接到地和5V引腳。至于蜂鳴器,它只接地和模擬輸出引腳A0。一旦你為雷達(dá)附加了所有必要的物品,你的電路應(yīng)該看起來(lái)有點(diǎn)像上圖。此外,盡量保持一切整潔!一旦電路在盒子里,電線都非常纏結(jié),有可能一根或兩根電線滑出不到位置并導(dǎo)致雷達(dá)發(fā)生故障。它發(fā)生在我身上,我發(fā)現(xiàn)它從那時(shí)起就保持整潔,減少了這些事件的發(fā)生。

步驟7:組裝

使用強(qiáng)力超級(jí)膠水組裝激光切割盒,因此完成后不會(huì)有碎片分開雷達(dá)。我發(fā)現(xiàn)更容易使用一些書來(lái)支撐盒子的一側(cè),這樣我就可以粘上相鄰的一面。在那里拿著它約5分鐘后,我會(huì)繼續(xù)到下一側(cè),依此類推。記住不要粘上其中一端,因?yàn)槟泔@然需要放入并取出雷達(dá)。一旦盒子上的膠水硬化,您就可以繼續(xù)裝配。首先,我將蜂鳴器粘在外殼的頂部(如上圖所示),然后當(dāng)它干燥時(shí),我將電線穿過(guò)相對(duì)的孔并將它們連接到蜂鳴器上。當(dāng)談到伺服系統(tǒng)時(shí),我將伺服的小翼粘在盒子下面,所以只有伺服的頂部顯示出來(lái)。這使得整個(gè)產(chǎn)品看起來(lái)既美觀又保持其實(shí)用性,伺服頭可隨時(shí)輕松訪問(wèn)。然后使用3D打印支架中的超聲波傳感器,使用膠水將支架連接到伺服系統(tǒng),以確保其安全。完成后,您的項(xiàng)目即可進(jìn)行測(cè)試!

步驟8:執(zhí)行

首先將計(jì)算機(jī)連接到arduino板。接下來(lái),打開兩個(gè)程序。加載arduino代碼后,將其上傳到主板。這應(yīng)該開始伺服和蜂鳴器,因此會(huì)產(chǎn)生噪音,伺服也會(huì)相應(yīng)轉(zhuǎn)動(dòng)。然后,當(dāng)加載處理代碼時(shí),單擊運(yùn)行,如果一切順利運(yùn)行,則應(yīng)顯示雷達(dá)的動(dòng)畫。如果沒有發(fā)生這種情況,請(qǐng)檢查您使用的端口名稱是否與代碼中的名稱完全相同。例如,如果我使用端口“/dev/cu.usbmodem143401”,請(qǐng)確保處理中的代碼行顯示“myPort = new Serial(this,”/dev/cu.usbmodem143401“,9600);”。這應(yīng)該解決所有問(wèn)題,它應(yīng)該運(yùn)行順利。啟動(dòng)和運(yùn)行的過(guò)程都可以在上面的視頻鏈接上看到它正在工作和檢測(cè)對(duì)象。

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 雷達(dá)
    +關(guān)注

    關(guān)注

    50

    文章

    3119

    瀏覽量

    120119
  • Arduino
    +關(guān)注

    關(guān)注

    190

    文章

    6498

    瀏覽量

    192187
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    免費(fèi)分享Arduino入門+進(jìn)階(全套例程+書籍)

    Arduino是一款開源電子原型平臺(tái),由硬件(單片機(jī)開發(fā)板)和軟件(編程環(huán)境)組成,旨在讓非專業(yè)用戶也能輕松入門電子制作和編程。它的核心思想是簡(jiǎn)化硬件開發(fā),通過(guò)直觀的編程和模塊化設(shè)計(jì),讓用戶快速實(shí)現(xiàn)
    的頭像 發(fā)表于 05-22 11:40 ?265次閱讀
    免費(fèi)分享<b class='flag-5'>Arduino</b>入門+進(jìn)階(全套例程+書籍)

    《ESP32S3 Arduino開發(fā)指南》第二章 Arduino基礎(chǔ)知識(shí)

    完成一個(gè)電子產(chǎn)品的制作。這就給開源硬件的推廣和普及設(shè)定了一個(gè)很高的門檻,電子愛好者需要花很多時(shí)間和精力才能開始開發(fā)和制作自己的作品。而使用Arduino能很快地完成一個(gè)電子產(chǎn)品的制作
    發(fā)表于 05-13 09:28

    定華雷達(dá)儀表學(xué)堂:高頻雷達(dá)物位計(jì)與低頻雷達(dá)物位計(jì)的優(yōu)缺點(diǎn)

    ?一般來(lái)說(shuō),雷達(dá)物位計(jì)的頻率越高,則波長(zhǎng)越短,且發(fā)射的信號(hào)越強(qiáng)、越精確,同時(shí),對(duì)于水汽的存在和掛料程度也越加敏感,因此高頻雷達(dá)物位計(jì)通常只用于測(cè)量固體料位。相反,如果頻率越低,則波長(zhǎng)越長(zhǎng),且更容易
    的頭像 發(fā)表于 02-14 10:35 ?435次閱讀

    定華雷達(dá)儀表學(xué)堂:如何判斷雷達(dá)物位計(jì)正常工作?

    雷達(dá)物位計(jì)在行業(yè)內(nèi)的應(yīng)用日益廣泛,根據(jù)一些具體情況判斷雷達(dá)物位計(jì)是否正常工作,我們介紹如何判斷出雷達(dá)物位計(jì)是否正常工作,如以下內(nèi)容: 1、首先檢查雷達(dá)物位計(jì)在現(xiàn)場(chǎng)的安裝使用情況、安裝是
    的頭像 發(fā)表于 01-20 14:16 ?398次閱讀

    Arduino采集雷達(dá)模塊數(shù)據(jù)與串口繪圖

    Arduino采集雷達(dá)模塊數(shù)據(jù)與串口繪圖
    的頭像 發(fā)表于 12-14 11:44 ?844次閱讀
    <b class='flag-5'>Arduino</b>采集<b class='flag-5'>雷達(dá)</b>模塊數(shù)據(jù)與串口繪圖

    OLED 顯示雷達(dá)數(shù)據(jù)

    使用螢火工場(chǎng)CEM5826-M11雷達(dá)模塊,Arduino IDE 編譯代碼,OLED顯示雷達(dá)數(shù)據(jù)
    的頭像 發(fā)表于 12-10 13:38 ?604次閱讀
    OLED 顯示<b class='flag-5'>雷達(dá)</b>數(shù)據(jù)

    自己設(shè)計(jì)的Arduino UNO R3主控板原理圖+PCB源文件(可直接打樣)

    一年前做的Arduino UNO r3,開源精神,把自己這塊板子奉獻(xiàn)給大家,板子沒有什么問(wèn)題,可以直接打樣制作,原理圖文件都表明了型號(hào)。不用謝~ Arduino UNO R3主控板原理圖部分截圖: *附件:MYArduino
    發(fā)表于 12-10 10:14

    開源項(xiàng)目!基于 Arduino 的 MIDI 架子鼓

    牢固地固定在插槽中。 第 6 步:給鼓墊接線 1、固定電纜: 使用熱膠將帶狀電纜連接到墊子上。 2、焊接鼓墊: 通過(guò)焊接將鼓墊連接到多頻段帶狀電纜。 第 7 步:制作 Arduino 擴(kuò)展板 1
    發(fā)表于 11-25 12:00

    基于Arduino的串口通信項(xiàng)目

    基于Arduino的串口通信項(xiàng)目涉及多個(gè)方面,包括硬件連接、軟件編程、串口參數(shù)配置等。 一、硬件準(zhǔn)備 Arduino開發(fā)板 :確保你有一塊Arduino開發(fā)板,如Arduino Uno
    的頭像 發(fā)表于 11-22 09:24 ?2188次閱讀

    定華雷達(dá)儀表學(xué)堂:雷達(dá)液位計(jì)的導(dǎo)波管的使用注意事項(xiàng)

    在安裝時(shí)對(duì)導(dǎo)波管有其要求,要求導(dǎo)波管內(nèi)徑等于102.3毫米,壁厚6毫米,且安裝要求垂直偏差小于+/-0.5度。 ? 2、雷達(dá)液位計(jì)底部需制作一個(gè)支撐架,與導(dǎo)波管的間隙為15~30毫米,減少進(jìn)料時(shí)湍流的沖擊,導(dǎo)波管底部還需安裝反射板和校
    的頭像 發(fā)表于 11-20 17:24 ?627次閱讀

    stm32與Arduino的比較

    在微控制器的世界里,STM32和Arduino是兩個(gè)經(jīng)常被提及的名字。STM32是一系列由STMicroelectronics生產(chǎn)的高性能微控制器,而Arduino則是一個(gè)開源電子原型平臺(tái),基于易于
    的頭像 發(fā)表于 11-19 15:45 ?4190次閱讀

    相控陣雷達(dá)電源芯片詳解

    一相控陣雷達(dá)簡(jiǎn)介 相控陣雷達(dá)即相位控制電子掃描陣列雷達(dá),其快速而精確轉(zhuǎn)換波束的能力使雷達(dá)能夠在1min內(nèi)完成全空域的掃描。所謂相控陣雷達(dá)是由
    發(fā)表于 11-17 10:53

    汽車雷達(dá)回波發(fā)生器的技術(shù)原理和應(yīng)用場(chǎng)景

    汽車雷達(dá)回波發(fā)生器是一種新型的雷達(dá)測(cè)試設(shè)備,以下是對(duì)其技術(shù)原理和應(yīng)用場(chǎng)景的詳細(xì)介紹:技術(shù)原理汽車雷達(dá)設(shè)備在發(fā)送電磁波信號(hào)時(shí),若遇到目標(biāo)物體,該物體會(huì)反射出回波信號(hào),隨后被雷達(dá)接收機(jī)捕獲
    發(fā)表于 11-15 14:06

    如何使用Arduino實(shí)現(xiàn)CAN總線通信

    CAN總線(Controller Area Network)是一種多主控制的串行通信協(xié)議,廣泛應(yīng)用于汽車電子、工業(yè)自動(dòng)化等領(lǐng)域。它以其高可靠性、實(shí)時(shí)性和靈活性而受到青睞。Arduino作為一個(gè)
    的頭像 發(fā)表于 11-12 10:09 ?2719次閱讀

    光學(xué)雷達(dá)和激光雷達(dá)的區(qū)別是什么

    光學(xué)雷達(dá)和激光雷達(dá)是兩種不同的遙感技術(shù),它們?cè)谠?、?yīng)用、優(yōu)缺點(diǎn)等方面都存在一定的差異。以下是對(duì)光學(xué)雷達(dá)和激光雷達(dá)的比較: 定義和原理 光學(xué)雷達(dá)
    的頭像 發(fā)表于 08-29 17:20 ?3269次閱讀