Mundarija:

Arduino Vr: 4 qadam
Arduino Vr: 4 qadam

Video: Arduino Vr: 4 qadam

Video: Arduino Vr: 4 qadam
Video: Amazing arduino project 2024, Noyabr
Anonim
Arduino Vr
Arduino Vr

Salom Mening ismim Kristian, men 13 yoshdaman. Men arduino -ni yaxshi ko'raman va buning uchun iste'dodim bor, shuning uchun men arduino vr uchun ko'rsatma beraman.

Ta'minotlar

Ta'minot:

1. Arduino taxtasi Mega, Due, Uno yoki Yun.

2. Erkak -erkak (standart o'tish simlari) simlari.

3. Kichkina non paneli

4. USB

5. GY-521 MPU-6050

Majburiy emas:

6. 5,5 dyuymli 2560*1440 2K LCD displeyli HDMI - MIPI

7. Fresnel linzalari Fokus uzunligi 50 mm

8. 3 o'lchamli printer yoki 3d printer xizmati

1 -qadam: yig'ish

Yig'ish
Yig'ish

Uni birlashtirish uchun sxemadan foydalaning.

2 -qadam: Kutubxonani qanday o'rnatish kerak?

Github -ga qarang: https://github.com/relativty/Relativ Siz uni Git yoki to'g'ridan -to'g'ri yuklab olish yordamida o'rnatishingiz mumkin.

3 -qadam: kod

// i2cdevlib va MPU6050 kerak:

// Ajoyib Jeff Rowberg <3 uchun katta rahmat, MPU6050 haqida ko'proq bilib olish uchun uning reposini tekshiring. // =============================================== ============================

// I2Cdev va MPU6050 kutubxonalar sifatida o'rnatilishi kerak, aks holda.cpp/.h fayllari // har ikkala sinf uchun ham loyihangizning qo'shilish yo'lida bo'lishi kerak.

#"Relativ.h" ni qo'shing

#"I2Cdev.h" ni qo'shing

#"MPU6050_6Axis_MotionApps20.h" ni qo'shing

#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #"Wire.h" ni qo'shing #endif

MPU6050 MPa; Nisbiy nisbiylik;

#INTERRUPT_PIN 2 ni aniqlang

// IMU holati va nazorati: bool dmpReady = false; // rost, agar DMP init muvaffaqiyatli bo'lsa uint8_t mpuIntStatus; uint8_t devStatus; // 0 = muvaffaqiyat,! 0 = xato uint16_t packetSize; uint16_t fifoCount; uint8_t fifoBuffer [64];

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

o'zgaruvchan bool mpuInterrupt = false; // MPU uzilish pimi yuqori bo'shliqqa aylanganligini ko'rsatadi dmpDataReady () {mpuInterrupt = true; }

void setup () {#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin (); Wire.setClock (400000); // 400 kHz chastotali I2C. Kompilyatsiya qilishda qiyinchiliklar bo'lsa, bu qatorga izoh bering #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire:: setup (400, true); #endif

relativ.startNative (); // "startNative" 32 bitli ARM yadroli mikrokontroller uchun ishlatilishi mumkin, bu mahalliy Arduino DUE // kabi tavsiya etilgan //. // Relativ.start (); // "boshlang'ich" Arduino MEGA, Arduino UNO kabi NON-NATIVE USB mikrokontroller uchun.. // Ular ancha sekin. mpu.initialize (); pinMod (INTERRUPT_PIN, INPUT);

SerialUSB.println (mpu.testConnection ()? F ("MPU6050 ulanishi muvaffaqiyatli"): F ("MPU6050 ulanmagan"));

// DMP ni sozlash devStatus = mpu.dmpInitialize ();

// ================================= // bu erda o'z gyro ofsetlarini etkazib bering: // === =============================== mpu.setXGyroOffset (220); mpu.setYGyroOffset (76); mpu.setZGyroOffset (-85); mpu.setZAccelOffset (1788);

// devSTatus agar hamma narsa to'g'ri ishlagan bo'lsa (devStatus == 0) {// DMP ni yoqing, hozir u tayyor mpu.setDMPEnabled (rost);

// Arduino uzilishni aniqlashni qo'shish attachInterrupt (digitalPinToInterrupt (INTERRUPT_PIN), dmpDataReady, RISING); mpuIntStatus = mpu.getIntStatus ();

dmpReady = rost;

// keyinchalik taqqoslash uchun kutilgan DMP paket hajmini oling packetSize = mpu.dmpGetFIFOPacketSize (); } boshqa {// XATO! }}

void loop () {// Agar (! dmpReady) qaytsa DMP to'g'ri boshlanmasa, hech narsa qilmang;

// (! mpuInterrupt && fifoCount <packetSize) {} vaqtida MPU uzilishi yoki qo'shimcha paketlar mavjud bo'lishini kuting.

// uzilish bayrog'ini tiklang va INT_STATUS baytini oling mpuInterrupt = false; mpuIntStatus = mpu.getIntStatus ();

// joriy FIFO sonini oling fifoCount = mpu.getFIFOCount ();

agar ((mpuIntStatus & 0x10) || fifoCount == 1024) {mpu.resetFIFO (); } // if (mpuIntStatus & 0x02) {while (fifoCount <packetSize) fifoCount = mpu.getFIFOCount (); mpu.getFIFOBytes (fifoBuffer, packetSize); fifoCount -= packetSize; mpu.dmpGetQuaternion (& q, fifoBuffer); relativ.updateOrientationNative (q.x, q.y, q.z, q.w, 4); // updateOrientationNative "tavsiya etilgan Arduino DUE // kabi Native USB bilan ishlaydigan 32 bitli ARM yadroli mikrokontroller uchun ishlatilishi mumkin. //relativ.updateOrientation(qx, qy, qz, qw, 4); // Relativ.updateOrientation" NON-NATIVE USB mikrokontroller uchun, masalan Arduino MEGA, Arduino UNO.. // Ular ancha sekin. }}

4 -qadam: O'ynang

har qanday vr o'yinida kichik taxtani ko'chirish kamerani aylantirishi kerak

Tavsiya: