Mundarija:

Arduino yordamida virtual reallik kostyumi: 7 qadam (rasmlar bilan)
Arduino yordamida virtual reallik kostyumi: 7 qadam (rasmlar bilan)

Video: Arduino yordamida virtual reallik kostyumi: 7 qadam (rasmlar bilan)

Video: Arduino yordamida virtual reallik kostyumi: 7 qadam (rasmlar bilan)
Video: Amazing arduino project 2024, Noyabr
Anonim
Arduino yordamida virtual haqiqat kostyumi
Arduino yordamida virtual haqiqat kostyumi

Men ushbu loyihani oddiy kompyuter o'yinlarini to'liq VR rejimida o'ynash uchun yaratdim. Ushbu loyiha sizning harakatlaringizni klaviatura tugmachalarini bosib ushlab turishga taqlid qiladi

Misol- oldinga siljiganingizda "w" tugmachasini bosish harakati taqlid qilinadi.

Men Call of Duty 4: Modern Warfare o'yinini taqlid qildim, lekin tortishish paytida orqaga qaytadigan o'yinlarni tanlamang, chunki u sichqonchaning asl holatini o'zgartiradi.

1 -qadam: talablar

Talablar-

Bu kostyumni tayyorlash uchun kerak bo'lgan narsalar ro'yxati bor

Sensorli sensorlar-5

Kuch sensori-1

GPU 6050 - 4

(yoki)

GPU 6050 - 2 va akselerometr - 2

Vr ko'zoynaklar

Vr yoqilgan telefon

Kompyuter

Wi -Fi ulanish nuqtasi

O'yinchoq qurol

Kompyuter o'yini (men Call of Duty- Modern Warfare 1-dan foydalanganman)

Non paneli simlari (erkak-ayol)

ARDUINO LEONARDO-2

Avtomatik qobiq - 2

Quvvat manbai (lipo)

Kamalak simlari

2 -qadam: QURILMA

QURILMA
QURILMA
QURILMA
QURILMA
QURILMA
QURILMA

*reload_pin, shoot_pin, tungi ko'rish_pin, granata_pin, qurol almashtirish_pin - sensorli sensorlar. aim_pin - bu kuch sensori va sichqoncha MPU6050 tomonidan taqlid qilinadi, boshqa sensorlar akselerometrdir (duruş, harakat1 va 2).

1.1) Lehimlash

SOLDER MPU 6050, akselerometr, sensorli sensorlar va simli kuch sensori

1.2) simlar

MPU 6050 uchun

2-pin- SDA

3-pin- SCL

GND - GND

5V - PWR/VCC

Harakat_pin1 uchun-

Pin A1- x o'qi

GND-GND

5V - PWR/VCC

Harakat_pin2 uchun-

Pin A2- x o'qi

GND-GND

5V - PWR/VCC

Posture_pin uchun-

A0- x o'qi

GND-GND

5V - PWR/VCC

qurol_pin uchun -

sig-5v

GND-GND

5V - PWR/VCC

Reload_pin uchun -

pin12 - 5v

GND-GND

5V - PWR/VCC

Nightvision_pin uchun -

pin 10 - 5V

GND-GND

5V - PWR/VCC

Shoot_pin uchun -

Pin 7 - 5v

GND-GND

5V - PWR/VCC

Aim_pin uchun -

Pin 8 - 5v

5V - PWR/VCC

1.3) LAYHLANISH TELLARI

Non paneli simlarini kamalak simlari bilan lehimlang

1.4) YALITISH

Qisqa tutashuvlarning oldini olish uchun payvandlangan joyga simlarni izolyatsiya tasmasi bilan yopishtiring

3 -qadam: dasturiy ta'minot

Dasturiy ta'minot
Dasturiy ta'minot
Dasturiy ta'minot
Dasturiy ta'minot

Men videoni noutbukdan telefonga uzatish uchun Play do'konidagi "Remotr" ilovasidan foydalandim

2.1) REMOTR-

Kompyuteringizga REMOTR dasturini o'rnating va hisob yarating

Mana havola-

remotrapp.com/#download

Smartfoningizga REMOTR ilovasini o'rnating

2.2) VIDEO STREAM

Avval kompyuterni va bir xil Wi -Fi tarmog'ini ulang va ikkala qurilmada ham REMOTR hisob qaydnomangizni kiriting

Endi dasturiy ta'minotda uzatmoqchi bo'lgan o'yinni qo'lda qo'shing

Endi ilova kompyuterni administrator sifatida ko'rsatadi, oqimni boshlash uchun uni bosing

VR rejimida translyatsiya qilish uchun smartfonda vr rejimini yoqing

Agar siz tushunmasangiz, batafsil ma'lumot uchun ushbu havolani tekshiring

remotrapp.com/uz/howto

4 -qadam: Asosiy kod

Ushbu loyihaning kodi murakkab yoki murakkab emas, lekin uzoq

Bu erda kod faqat nusxa ko'chiring va arduino faylingizga joylashtiring

ARDUINO

LEONARDO sichqonchasi-

Men Gabry295 ni takrorladim. Bu sichqoncha kodi uning boshiga asoslangan Sichqoncha ko'rsatma

#qo'shing

#qo'shing

#qo'shing

#qo'shing

int aim_pin;

int shoot_pin;

MPU6050 MPa;

int16_t ax, ay, az, gx, gy, gz;

int vx, vy;

bo'sh o'rnatish () {

Serial.begin (9600);

Sichqoncha.begin ();

Wire.begin ();

mpu.initialize ();

agar (! mpu.testConnection ()) {

vaqt (1);

}

pinMode (7, INPUT);

pinMode (8, INPUT);

}

void loop () {

shoot_pin = digitalRead (7);

aim_pin = digitalRead (8);

mpu.getMotion6 (& ax, & ay, & az, & gx, & gy, & gz);

vx = (gx-300)/200; // Men -300 va +490 ni qo'ydim, chunki mpu6050 chekni siljitganda bu qiymatlarni ko'rsatadi

vy = -(gz+490)/200; // bu qiymatlar haqida qo'shimcha ma'lumot olish uchun Gabry295 tomonidan bosh sichqonchasi kodini tekshiring

Sichqoncha harakati (vx, vy);

kechikish (20);

while (shoot_pin == HIGH);

{

Sichqonchani bosing ();

}

while (aim_pin == HIGH);

{

Sichqonchani bosing ();

}

}

Leonardo klaviaturasi

#qo'shing

int granata;

int qurol_pin;

int reload_pin;

int harakati1_pin;

int harakati2_pin;

int posture_pin;

char nightvision_pin;

bo'sh o'rnatish ()

{

pinMode (7, Kirish);

pinMode (8, INPUT);

pinMod (9, Kirish);

pinMod (10, Kirish);

pinMode (11, INPUT);

pinMode (12, INPUT);

pinMode (A0, INPUT);

pinMode (A1, Kirish);

Keyboard.begin ();

}

bo'sh halqa ()

{

Grenade_pin = digitalRead (8);

qurol_pin = digitalRead (9);

motion1_pin = analogRead (A1);

motion2_pin = analogRead (A2);

posture_pin = analogRead (A0);

reload_pin = digitalRead (12);

nightvision_pin = digitalRead (10);

agar (granata == YUQORI)

{

Keyboard.press ('g');

}

vaqt (qurol_pin == YUQORI)

{

Keyboard.press ('q');

}

while (reload_pin == HIGH)

{

Keyboard.press ('r');

}

while (harakat1_pin> 340 && harakat1_pin <420)

{

Keyboard.press ('w');

}

vaqt (harakat1_pin> 420)

{

Keyboard.press ('w');

Keyboard.press ('p');

}

while (harakat2_pin> 340 && harakat2_pin <420)

{

Keyboard.press ('w');

}

vaqt (harakat2_pin> 420)

{

Keyboard.press ('p');

Keyboard.press ('w');

}

while (posture_pin> 340 && posture_pin <420)

{

Keyboard.press ('c');

}

vaqt (posture_pin> 420)

{

Keyboard.press ('l');

}

vaqt (posture_pin <340)

{

Keyboard.press ('z');

}

vaqt (nightvision_pin == YUQORI)

{

Keyboard.press ('n');

}

}

}

5 -qadam: TEST KODLARI

Bu erda funktsiya bo'yicha asosiy koddan ajratilgan bir nechta kodlar

OTISH-

#qo'shing

int x;

bo'sh o'rnatish () {

pinMode (8, INPUT);

Sichqoncha.begin ();

}

void loop () {

x = digitalRead (8);

agar (x == YUQORI)

{

Sichqonchani bosing ('g');

}

}

MAKSID-

#qo'shing

#qo'shing

#qo'shing

#qo'shing

MPU6050 MPa;

int16_t ax, ay, az, gx, gy, gz;

int vx, vy;

bo'sh o'rnatish () {

Serial.begin (9600);

Sichqoncha.begin ();

Wire.begin ();

mpu.initialize ();

agar (! mpu.testConnection ()) {

vaqt (1);

}

}

void loop () {

shoot_pin = digitalRead (7);

aim_pin = digitalRead (8);

mpu.getMotion6 (& ax, & ay, & az, & gx, & gy, & gz);

vx = (gx+300)/200; // "+300", chunki giroskopning x o'qi -350 atrofida, u qimirlamay turibdi. Agar siz TEST kodini ishlatib, noldan uzoqroq qiymatlar bo'lsa, chacking yordamida boshqa narsani olsangiz, bu qiymatni o'zgartiring.

vy = -(gz_ -100)/200; // bu erda "-100" haqida

Qayta yuklanmoqda-

#qo'shing

int x;

bo'sh o'rnatish () {

pinMode (8, INPUT);

Keyboard.begin ();

}

void loop () {

x = digitalRead (8);

agar (x == YUQORI)

{

Keyboard.press ('r');

}

boshqa

{

Keyboard.release ('r');

}

}

NIGHT VISIO #o'z ichiga oladi

int x;

bo'sh o'rnatish () {

pinMode (8, INPUT);

Keyboard.begin ();

}

void loop () {

x = digitalRead (8);

agar (x == YUQORI)

{

Keyboard.press ('g');

}

boshqa

{

Keyboard.release ('g');

}

}

KRUCH VA PRON-

#qo'shing

int y;

bo'sh o'rnatish () {

pinMode (A0, INPUT);

Serial.begin (9600);

}

void loop () {

y = analogRead (A0);

agar (y <260)

{

Keyboard.release ('c');

Keyboard.release ('p');

}

aks holda (y> 260 && y <310)

{

Keyboard.press ('c');

}

aks holda (y> 310)

{

Keyboard.press ('p');

}

}

6 -qadam: O'YINNI NAZORAT

O'yin boshqaruvini quyidagicha o'zgartiring

egilgan - x

moyil - l

qurol almashtirish - q

sprint - p

turish/sakrash - z

tungi ko'rish - n

oldinga harakat - v

granata - g

7 -qadam: O'rnatish

O'rnatish
O'rnatish
O'rnatish
O'rnatish
O'rnatish
O'rnatish

Nihoyat, biz arduino qo'yadigan oxirgi bosqichga keldik

taxtalarni qutiga solib, sumkaga soling

Endi arduino mikro USB -ni noutbukning USB portlariga ulang, datchiklarni yuqorida ko'rsatilgan tarzda ulang

*yuqoridagi rasmlardagi o'q belgilari sensorning yuzini ko'rsatishi kerak

Agar sizda biron bir shubha bo'lsa, sharh qoldirishdan tortinmang va tajribangiz bilan bo'lishishni unutmang

Bu sizga rahmat va

BYE.

Tavsiya: