Cov txheej txheem:

Arduino Vr: 4 Kauj Ruam
Arduino Vr: 4 Kauj Ruam

Video: Arduino Vr: 4 Kauj Ruam

Video: Arduino Vr: 4 Kauj Ruam
Video: Amazing arduino project 2024, Kaum ib hlis
Anonim
Arduino Uas
Arduino Uas

Nyob zoo Kuv lub npe yog Christian thiab kuv muaj 13 xyoos. Kuv nyiam arduino thiab muaj txuj ci rau nws yog li ntawm no yog kuv qhia rau arduino vr.

Khoom siv

Khoom siv:

1. Arduino board Mega, Due, Uno, lossis Yun.

2. Txiv neej rau txiv neej (tus qauv jumper xov hlau) xov hlau.

3. Cov ntawv me me

4. USB

5. GY-521 MPU-6050

Yeem:

6. 5.5 nti 2560*1440 2K LCD Screen HDMI rau MIPI

7. Fresnel lens Focal Length 50mm

8. 3-D tshuab luam ntawv lossis 3d tshuab luam ntawv pabcuam

Kauj ruam 1: Sib sau ua ke

Sib sau ua ke
Sib sau ua ke

Siv cov schematic los muab tso ua ke.

Kauj Ruam 2: Yuav Ua Li Cas Nruab Lub Tsev Qiv Ntawv?

Saib ntawm Github: https://github.com/relativty/Relativ Koj tuaj yeem nruab nws siv Git lossis rub tawm ncaj qha.

Kauj ruam 3: Code

// i2cdevlib thiab MPU6050 xav tau:

// Ua tsaug ntau rau qhov ua tau zoo Jeff Rowberg <3, mus xyuas nws cov repo kom kawm paub ntau ntxiv MPU6050. // ======================================================== ================================

// I2Cdev thiab MPU6050 yuav tsum tau teeb tsa ua lub tsev qiv ntawv, lossis lwm qhov.cpp/.h cov ntaub ntawv // rau ob chav kawm yuav tsum muaj nyob hauv txoj hauv kev ntawm koj txoj haujlwm

#suav nrog "Relativ.h"

#suav nrog "I2Cdev.h"

#suav nrog "MPU6050_6Axis_MotionApps20.h"

#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #suav nrog "Wire.h" #endif

MPU6050 mpu; Txheeb sib txheeb;

#define INTERRUPT_PIN 2

// IMU xwm txheej thiab tswj: bool dmpReady = cuav; // muaj tseeb yog tias DMP pib ua tiav uint8_t mpuIntStatus; uint8_t devStatus; // 0 = ua tiav,! 0 = yuam kev uint16_t packetSize; uint16_t fifoCount; uint8_t fifoBuffer [64];

Quaternion q; // [w, x, y, z]

volatile bool mpuInterrupt = cuav; // qhia seb MPU cuam tshuam tus pin tau ploj mus tsis muaj dab tsi dmpDataReady () {mpuInterrupt = muaj tseeb; }

void teeb () {#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin (); Wire.setClock (400000); // 400kHz I2C moos. Tawm tswv yim kab ntawv no yog tias muaj teeb meem sau ua ke #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire:: teeb tsa (400, muaj tseeb); #ib

relativ.startNative (); // "startNative" tuaj yeem siv rau 32-ntsis ARM core microcontroller nrog Native USB zoo li Arduino DUE // uas tau pom zoo. // Relativ.start (); // "pib" yog rau NON-NATIVE USB microcontroller, zoo li Arduino MEGA, Arduino UNO.. // Cov ntawd qeeb qeeb. mpu.initialize (); pinMode (INTERRUPT_PIN, INPUT);

SerialUSB.println (mpu.testConnection ()? F ("MPU6050 kev sib txuas ua tiav"): F ("MPU6050 txuas tsis tau"));

// teeb tsa DMP devStatus = mpu.dmpInitialize ();

// ================================== // muab koj tus kheej gyro offsets ntawm no: // === =============================== mpu.setXGyroOffset (220); mpu.setYGyroOffset (76); mpu.setZGyroOffset (-85); mpu.setZAccelOffset (1788);

// devSTatus yog tias txhua yam ua haujlwm tau zoo yog tias (devStatus == 0) {// qhib DMP, tam sim no nws tau npaj mpu.setDMPEnabled (muaj tseeb);

// pab kom Arduino cuam tshuam kev txheeb xyuas qhov cuam tshuam cuam tshuam (digitalPinToInterrupt (INTERRUPT_PIN), dmpDataReady, RISING); mpuIntStatus = mpu.getIntStatus ();

dmpReady = muaj tseeb;

// tau txais kev cia siab DMP pob ntawv loj rau tom qab sib piv packetSize = mpu.dmpGetFIFOPacketSize (); } lwm {{ERROR! }}

void loop () {// Tsis ua dab tsi yog DMP tsis pib ua kom raug yog (! dmpReady) rov qab;

// tos MPU cuam tshuam lossis pob ntawv ntxiv kom muaj thaum (! mpuInterrupt && fifoCount <packetSize) {}

// rov pib cuam tshuam tus chij thiab tau INT_STATUS byte mpuInterrupt = cuav; mpuIntStatus = mpu.getIntStatus ();

// tau txais FIFO suav tam sim no fifoCount = mpu.getFIFOCount ();

yog ((mpuIntStatus & 0x10) || fifoCount == 1024) {mpu.resetFIFO (); } // kos rau cuam tshuam lwm tus yog (mpuIntStatus & 0x02) {thaum (fifoCount <packetSize) fifoCount = mpu.getFIFOCount (); mpu.getFIFOBytes (fifoBuffer, pob ntawv loj); fifoCount -= packetSize; mpu.dmpGetQuaternion (& q, fifoBuffer); relativ.updateOrientationNative (q.x, q.y, q.z, q.w, 4); // updateOrientationNative "tuaj yeem siv rau 32-ntsis ARM core microcontroller nrog Native USB zoo li Arduino DUE // uas tau pom zoo. //relativ.updateOrientation(qx, qy, qz, qw, 4); // Relativ.updateOrientation" yog rau NON-NATIVE USB microcontroller, zoo li Arduino MEGA, Arduino UNO.. // Cov ntawd qeeb qeeb. }}

Kauj ruam 4: Ua si

txav lub rooj me me ntawm txhua qhov vr game yuav tsum tig lub koob yees duab

Pom zoo: