chinese直男口爆体育生外卖, 99久久er热在这里只有精品99, 又色又爽又黄18禁美女裸身无遮挡, gogogo高清免费观看日本电视,私密按摩师高清版在线,人妻视频毛茸茸,91论坛 兴趣闲谈,欧美 亚洲 精品 8区,国产精品久久久久精品免费

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

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

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

如何制作數(shù)字指南針

454398 ? 來源:wv ? 2019-10-12 14:19 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

第1步:所需零件

對于此項目,您將只需要一個Arduino開發(fā)板和一個MEMS磁力計即可測量地磁場。我將使用包含MC5883L 3軸磁力計的GY – 80分支板。

在繼續(xù)執(zhí)行該項目的源代碼之前,如果您需要更多詳細信息,請參見MEMS磁力計如何工作以及如何通過I2C通信連接和使用GY-80接線板,

第2步:Arduino源代碼

我們首先需要做的是將草圖上傳到Arduino板,該板將讀取來自磁力計的數(shù)據(jù),并將其發(fā)送到Processing IDE。這是Arduino源代碼:

/* Arduino Compass

*

* by Dejan Nedelkovski,

* www.HowToMechatronics.com

*

*/

#include //I2C Arduino Library

#define Magnetometer_mX0 0x03

#define Magnetometer_mX1 0x04

#define Magnetometer_mZ0 0x05

#define Magnetometer_mZ1 0x06

#define Magnetometer_mY0 0x07

#define Magnetometer_mY1 0x08

int mX0, mX1, mX_out;

int mY0, mY1, mY_out;

int mZ0, mZ1, mZ_out;

float heading, headingDegrees, headingFiltered, declination;

float Xm,Ym,Zm;

#define Magnetometer 0x1E //I2C 7bit address of HMC5883

void setup(){

//Initialize Serial and I2C communications

Serial.begin(115200);

Wire.begin();

delay(100);

Wire.beginTransmission(Magnetometer);

Wire.write(0x02); // Select mode register

Wire.write(0x00); // Continuous measurement mode

Wire.endTransmission();

}

void loop(){

//---- X-Axis

Wire.beginTransmission(Magnetometer); // transmit to device

Wire.write(Magnetometer_mX1);

Wire.endTransmission();

Wire.requestFrom(Magnetometer,1);

if(Wire.available()《=1)

{

mX0 = Wire.read();

}

Wire.beginTransmission(Magnetometer); // transmit to device

Wire.write(Magnetometer_mX0);

Wire.endTransmission();

Wire.requestFrom(Magnetometer,1);

if(Wire.available()《=1)

{

mX1 = Wire.read();

}

//---- Y-Axis

Wire.beginTransmission(Magnetometer); // transmit to device

Wire.write(Magnetometer_mY1);

Wire.endTransmission();

Wire.requestFrom(Magnetometer,1);

if(Wire.available()《=1)

{

mY0 = Wire.read();

}

Wire.beginTransmission(Magnetometer); // transmit to device

Wire.write(Magnetometer_mY0);

Wire.endTransmission();

Wire.requestFrom(Magnetometer,1);

if(Wire.available()《=1)

{

mY1 = Wire.read();

}

//---- Z-Axis

Wire.beginTransmission(Magnetometer); // transmit to device

Wire.write(Magnetometer_mZ1);

Wire.endTransmission();

Wire.requestFrom(Magnetometer,1);

if(Wire.available()《=1)

{

mZ0 = Wire.read();

}

Wire.beginTransmission(Magnetometer); // transmit to device

Wire.write(Magnetometer_mZ0);

Wire.endTransmission();

Wire.requestFrom(Magnetometer,1);

if(Wire.available()《=1)

{

mZ1 = Wire.read();

}

//---- X-Axis

mX1=mX1《《8;

mX_out =mX0+mX1; // Raw data

// From the datasheet: 0.92 mG/digit

Xm = mX_out*0.00092; // Gauss unit

//* Earth magnetic field ranges from 0.25 to 0.65 Gauss, so these are the values that we need to get approximately.

//---- Y-Axis

mY1=mY1《《8;

mY_out =mY0+mY1;

Ym = mY_out*0.00092;

//---- Z-Axis

mZ1=mZ1《《8;

mZ_out =mZ0+mZ1;

Zm = mZ_out*0.00092;

// ==============================

//Calculating Heading

heading = atan2(Ym, Xm);

// Correcting the heading with the declination angle depending on your location

// You can find your declination angle at: http://www.ngdc.noaa.gov/geomag-web/

// At my location it‘s 4.2 degrees =》 0.073 rad

declination = 0.073;

heading += declination;

// Correcting when signs are reveresed

if(heading 《0) heading += 2*PI;

// Correcting due to the addition of the declination angle

if(heading 》 2*PI)heading -= 2*PI;

headingDegrees = heading * 180/PI; // The heading in Degrees unit

// Smoothing the output angle / Low pass filter

headingFiltered = headingFiltered*0.85 + headingDegrees*0.15;

//Sending the heading value through the Serial Port to Processing IDE

Serial.println(headingFiltered);

delay(50);

}

步驟3:處理IDE源代碼

在我們上傳了之前的Arduino草圖之后,我們需要將數(shù)據(jù)接收到Processing IDE中并繪制Digital Compass。指南針由背景圖像,箭頭的固定圖像和指南針主體的旋轉(zhuǎn)圖像組成。因此,使用Arduino計算出的耳磁場的值將用來旋轉(zhuǎn)羅盤。

以下是Processing IDE的源代碼:

/* Arduino Compass

*

* by Dejan Nedelkovski,

* www.HowToMechatronics.com

*

*/

import processing.serial.*;

import java.awt.event.KeyEvent;

import java.io.IOException;

Serial myPort;

PImage imgCompass;

PImage imgCompassArrow;

PImage background;

String data=“”;

float heading;

void setup() {

size (1920, 1080, P3D);

smooth();

imgCompass = loadImage(“Compass.png”);

imgCompassArrow = loadImage(“CompassArrow.png”);

background = loadImage(“Background.png”);

myPort = new Serial(this, “COM4”, 115200); // starts the serial communication

myPort.bufferUntil(’ ‘);

}

void draw() {

image(background,0, 0); // Loads the Background image

pushMatrix();

translate(width/2, height/2, 0); // Translates the coordinate system into the center of the screen, so that the rotation happen right in the center

rotateZ(radians(-heading)); // Rotates the Compass around Z - Axis

image(imgCompass, -960, -540); // Loads the Compass image and as the coordinate system is relocated we need need to set the image at -960x, -540y (half the screen size)

popMatrix(); // Brings coordinate system is back to the original position 0,0,0

image(imgCompassArrow,0, 0); // Loads the CompassArrow image which is not affected by the rotateZ() function because of the popMatrix() function

textSize(30);

text(“Heading: ” + heading,40,40); // Prints the value of the heading on the screen

delay(40);

}

// starts reading data from the Serial Port

void serialEvent (Serial myPort) {

data = myPort.readStringUntil(’ ‘);// reads the data from the Serial Port and puts it into the String variable “data”。

heading = float(data); // Convering the the String value into Float value

}

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

    關注

    2

    文章

    17

    瀏覽量

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

掃碼添加小助手

加入工程師交流群

    評論

    相關推薦
    熱點推薦

    ?STMicroelectronics LPS28DFW 數(shù)字氣壓計技術深度解析與應用指南

    STMicroelectronics LPS28DFW絕對數(shù)字輸出壓力計是一款超緊湊型壓阻式絕對壓力傳感器,可用作數(shù)字輸出氣壓計。LPS28DFW將傳感元件與通過I^2^C或MIPI I3CSM接口(從傳感元件到應用程序)進行通信的IC接口結(jié)合在一起。
    的頭像 發(fā)表于 10-31 11:24 ?262次閱讀
    ?STMicroelectronics LPS28DFW <b class='flag-5'>數(shù)字</b>氣壓計技術深度解析與應用<b class='flag-5'>指南</b>

    ?ILPS22QS數(shù)字氣壓計技術深度解析與應用指南

    STMicroelectronics ILPS22QS絕對數(shù)字輸出壓力計是一款超緊湊型壓阻式絕對壓力傳感器,可用作數(shù)字輸出氣壓計。ILPS22QS支持高達4060hPa用戶可選雙滿量程。ILPS22QS具有超低壓力噪聲和極低功耗。
    的頭像 發(fā)表于 10-31 11:17 ?223次閱讀
    ?ILPS22QS<b class='flag-5'>數(shù)字</b>氣壓計技術深度解析與應用<b class='flag-5'>指南</b>

    如何制作字母數(shù)字鍵盤?

    制作字母數(shù)字鍵盤
    發(fā)表于 09-05 07:24

    東映攜手奧拓刷新日本影視制作數(shù)字化標桿

    近日,由奧拓電子全程深度參與打造的“東映虛擬影棚”已正式發(fā)布啟用。這座凝聚前沿科技的虛擬影棚,不僅以640㎡的規(guī)模成為日本之最,更憑借頂尖技術配置,刷新了日本影視制作數(shù)字化標桿。作為日本首個由電影
    的頭像 發(fā)表于 06-04 15:21 ?840次閱讀

    01V96V2數(shù)字調(diào)音臺中文快速指南

    電子發(fā)燒友網(wǎng)站提供《01V96V2數(shù)字調(diào)音臺中文快速指南.pdf》資料免費下載
    發(fā)表于 03-26 14:19 ?0次下載

    不到千元輕松入手!華為云 Flexus 數(shù)字制作簡單、效果極佳

    數(shù)字化浪潮的席卷下,越來越多的數(shù)字人如雨后春筍般出現(xiàn)在大眾視野中,數(shù)字人熱度持續(xù)提升。然而,在這炙手可熱的背后,是數(shù)字人便捷的制作流程和逼
    的頭像 發(fā)表于 03-10 11:05 ?1034次閱讀
    不到千元輕松入手!華為云 Flexus <b class='flag-5'>數(shù)字</b>人<b class='flag-5'>制作</b>簡單、效果極佳

    不到千元體驗最新數(shù)字人技術!華為云 Flexus 數(shù)字人效果領先更超值

    當下,數(shù)字人的應用已經(jīng)非常廣泛,徹底走進了我們的日常生活。在教育領域,可以看到數(shù)字人被用于制作教學視頻,通過模擬真實的教師講解,為學生提供生動、直觀的學習材料;在政府服務大廳,有數(shù)字
    的頭像 發(fā)表于 03-10 11:04 ?711次閱讀
    不到千元體驗最新<b class='flag-5'>數(shù)字</b>人技術!華為云 Flexus <b class='flag-5'>數(shù)字</b>人效果領先更超值

    三部門關于印發(fā)《制造業(yè)企業(yè)數(shù)字化轉(zhuǎn)型實施指南》的通知

    ? ? 制造業(yè)企業(yè)數(shù)字化轉(zhuǎn)型實施指南 制造業(yè)數(shù)字化轉(zhuǎn)型是運用數(shù)字技術對制造業(yè)研發(fā)生產(chǎn)?全流程和產(chǎn)業(yè)鏈供應鏈各環(huán)節(jié)進行改造升級和價值重塑的?過程,是制造業(yè)高質(zhì)量發(fā)展的關鍵路徑。?制造業(yè)企
    的頭像 發(fā)表于 01-23 09:37 ?622次閱讀
    三部門關于印發(fā)《制造業(yè)企業(yè)<b class='flag-5'>數(shù)字</b>化轉(zhuǎn)型實施<b class='flag-5'>指南</b>》的通知

    dsPIC33CK512MP606數(shù)字電源接插模塊(PIM)用戶指南

    電子發(fā)燒友網(wǎng)站提供《dsPIC33CK512MP606數(shù)字電源接插模塊(PIM)用戶指南.pdf》資料免費下載
    發(fā)表于 01-21 14:51 ?1次下載
    dsPIC33CK512MP606<b class='flag-5'>數(shù)字</b>電源接插模塊(PIM)用戶<b class='flag-5'>指南</b>

    DAC8760的數(shù)字地和模擬地能否不連呢?

    of the device)。 雖然名稱都是GND,但有數(shù)字地和模擬地之分。產(chǎn)品手冊上的所有電路范例都是數(shù)字地和模擬地相連的。是否可以用兩套互相隔離的電源,分別作數(shù)字電源和模擬電源(數(shù)字
    發(fā)表于 01-14 06:24

    GY/T 318-2018 地面數(shù)字電視廣播單頻網(wǎng)系統(tǒng)實施指南

    電子發(fā)燒友網(wǎng)站提供《GY/T 318-2018 地面數(shù)字電視廣播單頻網(wǎng)系統(tǒng)實施指南.pdf》資料免費下載
    發(fā)表于 01-13 13:57 ?0次下載

    帶EQ和2頻段DRC的25W數(shù)字輸入放大器用戶指南

    電子發(fā)燒友網(wǎng)站提供《帶EQ和2頻段DRC的25W數(shù)字輸入放大器用戶指南.pdf》資料免費下載
    發(fā)表于 12-23 14:30 ?1次下載
    帶EQ和2頻段DRC的25W<b class='flag-5'>數(shù)字</b>輸入放大器用戶<b class='flag-5'>指南</b>

    多種傳感器集成,IMU助力無人機穩(wěn)定飛行

    常見的傳感器包括陀螺儀、加速度計、磁力計(指南針)、氣壓計(高度計)和GPS模塊,大多數(shù)IMU只集成陀螺儀和加速度計。
    的頭像 發(fā)表于 12-18 14:34 ?1716次閱讀
    多種傳感器集成,IMU助力無人機穩(wěn)定飛行

    ISO784xx四通道數(shù)字隔離器EVM用戶指南

    電子發(fā)燒友網(wǎng)站提供《ISO784xx四通道數(shù)字隔離器EVM用戶指南.pdf》資料免費下載
    發(fā)表于 12-09 15:07 ?0次下載
    ISO784xx四通道<b class='flag-5'>數(shù)字</b>隔離器EVM用戶<b class='flag-5'>指南</b>

    虛擬制作技術在廣告領域中的應用與挑戰(zhàn)

    技術的每一次革新都為創(chuàng)意的實現(xiàn)提供了更多可能。隨著虛擬制作技術日趨成熟及其在廣告領域全流程的應用,廣告內(nèi)容制作進入到了更高效的數(shù)字化時代。在剛剛落幕的第三屆上海國際虛擬制作大會暨展覽會
    的頭像 發(fā)表于 12-06 09:39 ?1327次閱讀