在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

如何制作Arduino雷達

454398 ? 來源:wv ? 2019-08-28 11:06 ? 次閱讀

第1步:材料和程序

此構建所需的材料包括:

- 1個伺服

- 1個超聲波傳感器

- 1個蜂鳴器

- 1面包板

- 1 UNO R3 Arduino

- 電線堆

制作此雷達所需的程序:

- Arduino IDE

- 處理3.4

要將上述程序下載到您的計算機上,請點擊以下鏈接:

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

-https://processing.org/download/

第2步:Arduino代碼

這是arduino代碼,它基本上控制伺服和傳感器的運動和輸入。這是從youtube視頻https://www.youtube.com/watch?v=JvmIutmQd9U復制而來,似乎與我的arduino板和計算機很好地配合。

// 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:處理代碼

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

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:超聲波傳感器支架

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

第5步:激光切割盒設計

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

步驟6:接線構造

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

步驟7:組裝

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

步驟8:執行

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

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • 雷達
    +關注

    關注

    50

    文章

    2970

    瀏覽量

    118084
  • Arduino
    +關注

    關注

    188

    文章

    6477

    瀏覽量

    187981
收藏 人收藏

    評論

    相關推薦

    Arduino采集雷達模塊數據與串口繪圖

    Arduino采集雷達模塊數據與串口繪圖
    的頭像 發表于 12-14 11:44 ?330次閱讀
    <b class='flag-5'>Arduino</b>采集<b class='flag-5'>雷達</b>模塊數據與串口繪圖

    OLED 顯示雷達數據

    使用螢火工場CEM5826-M11雷達模塊,Arduino IDE 編譯代碼,OLED顯示雷達數據
    的頭像 發表于 12-10 13:38 ?244次閱讀
    OLED 顯示<b class='flag-5'>雷達</b>數據

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

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

    開源項目!基于 Arduino 的 MIDI 架子鼓

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

    基于Arduino的串口通信項目

    基于Arduino的串口通信項目涉及多個方面,包括硬件連接、軟件編程、串口參數配置等。 一、硬件準備 Arduino開發板 :確保你有一塊Arduino開發板,如Arduino Uno
    的頭像 發表于 11-22 09:24 ?894次閱讀

    定華雷達儀表學堂:雷達液位計的導波管的使用注意事項

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

    相控陣雷達電源芯片詳解

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

    汽車雷達回波發生器的技術原理和應用場景

    汽車雷達回波發生器是一種新型的雷達測試設備,以下是對其技術原理和應用場景的詳細介紹:技術原理汽車雷達設備在發送電磁波信號時,若遇到目標物體,該物體會反射出回波信號,隨后被雷達接收機捕獲
    發表于 11-15 14:06

    如何使用Arduino實現CAN總線通信

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

    光學雷達和激光雷達的區別是什么

    光學雷達和激光雷達是兩種不同的遙感技術,它們在原理、應用、優缺點等方面都存在一定的差異。以下是對光學雷達和激光雷達的比較: 定義和原理 光學雷達
    的頭像 發表于 08-29 17:20 ?1833次閱讀

    相控陣雷達的原理和分類 相控陣雷達的特點

    相控陣雷達是一種利用相位控制技術來實現波束形成和方向控制的先進雷達系統。它的工作原理、分類和特點在現代電子戰和民用雷達系統中具有重要意義。
    的頭像 發表于 04-10 17:38 ?4900次閱讀

    如何用Arduino制作一個簡易自動喂魚器

    如果你家里養有魚,并想找到一種自動化喂食的方法,這個項目可能會對你有所啟發。 在這個教程中,作者將展示如何制作自己的基于Arduino的自動喂魚器,讓小魚不在餓肚子。 自動喂魚器的工作原理非常
    發表于 03-28 11:25

    雷達檢測概率曲線的影響因素

    在閱讀雷達書籍和相關論文時發現,雷達的檢測概率Pd和信噪比有一個函數關系 我的問題是如果這個函數關系是通用的,那么在門限一定的情況下,不同的雷達的檢測概率曲線是不是都一樣了?如果不是,那么
    發表于 03-27 19:54

    生命體征監測雷達模組

    SW-UWB-M-A2X2 是一款工作于 UWB 頻段的超寬帶人體監測雷達模組,可以在設定區域內以極高的靈敏度非接觸式感應人體的存在,測量人體的呼吸和心率,長時間監測后可以生成睡眠質量的分析報告
    發表于 03-06 09:51

    如何制作自己的Arduino電容計

    在這個項目中,您將學習如何制作自己的Arduino電容計(測量電容器的值,范圍從pF到1000的uF)。一般來說,電子愛好者喜歡設計自己的小工具而不是購買。在這個項目中,我們使用兩種電容測量方法,即
    的頭像 發表于 02-25 15:10 ?1748次閱讀
    如何<b class='flag-5'>制作</b>自己的<b class='flag-5'>Arduino</b>電容計
    主站蜘蛛池模板: 人人干人人爱 | 免费看国产一级特黄aa大片 | 亚洲香蕉国产高清在线播放 | 一级特级女人18毛片免费视频 | 欧美性色生活片天天看99 | 最近最新视频中文字幕4 | 69日本xxxxhd| 日韩免费 | 国模一区二区三区私啪啪 | 欧美色炮 | 99热最新在线 | 亚洲a视频 | 美女视频黄a视频美女大全 美女视频一区二区 | 国产午夜剧场 | 日本加勒比视频在线观看 | 91大神在线精品视频一区 | 中文字幕在线一区二区在线 | 在线观看你懂的视频 | 欧美a一级| 欧美黑人换爱交换乱理伦片 | 欧美三级免费看 | 97夜夜操| 日本三级在线观看免费 | 国内视频一区二区三区 | 色多多www视频在线观看免费 | 欧美一级欧美三级在线 | 色依依视频视频在线观看 | 男女交性视频播放视频视频 | 国产裸露片段精华合集链接 | 四虎影视在线看 | 欧美色图亚洲自拍 | 深爱开心激情网 | 国产成都一二三四区 | 成人亚洲欧美综合 | 国产午夜精品理论片在线 | 免费国产在线视频 | 丁香婷婷基地 | 91久久青草精品38国产 | 欧美婷婷色 | 1024手机在线观看你懂的 | 久久久免费网站 |