Spisu treści:

ITTT Rolando Ritzen - Rękawica Motion Control Arcade: 5 kroków
ITTT Rolando Ritzen - Rękawica Motion Control Arcade: 5 kroków

Wideo: ITTT Rolando Ritzen - Rękawica Motion Control Arcade: 5 kroków

Wideo: ITTT Rolando Ritzen - Rękawica Motion Control Arcade: 5 kroków
Wideo: Жизнь экспатов в Аргентине: прямая трансляция 2024, Lipiec
Anonim
ITTT Rolando Ritzen - Rękawica Motion Control Arcade
ITTT Rolando Ritzen - Rękawica Motion Control Arcade

Een handchoen die je kan gebruiken als motion controller voor on-rail shooters. De gimmick van dit project is dat alles motion control is, inclusief het schieten. (Je schiet door te „finger bangen”)

Krok 1: Materiał Het

Het materiaal dat je gaat nodig hebben is vrij simpel. 1x Arduino pro micro Arduino Leonardo1x żyroskop MPU6050

4x kabelki

Krok 2: De Bekabeling

De Bekabeling
De Bekabeling

Zoals je in het schema in de afbeelding ziet is de bekabeling super simpel. MPU VCC > Masa VCCMPU Arduino > Masa ArduinoMPU SCL > Pin 3MPU SDA > Pin 2

Krok 3: Biblioteki 1

Biblioteki 1
Biblioteki 1

Voor dit project heb je een paar custom library nodig van deze link:

Pobierz een plik ZIP przez de "Clone or download" knop rechts bovenaan.

Krok 4: Biblioteki 2

Biblioteki 2
Biblioteki 2

Otwórz plik zip i kliknij na mapie "Arduino". En uit deze Arduino map wil je de mapjes "I2Cdev" en "MPU6050" pakken en in je Arduino library zetten (Program Files > Arduino > biblioteki)

Krok 5: Kod de

#włączać

#include #include #include #include

MPU6050 mpu;

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

int16_t accx, accy, accz; int vx, vy; kąt pływania;

//kod wygładzający inputint readIndex = 0; const int numReadings = 20; int angleReadings[numReadings]; całkowita = 0; średni kąt zmiennoprzecinkowy = 0.0;

int stareZ = 0;

int nowyZ = 0;

void setup() { Serial.begin(115200); Wire.początek(); Mysz.początek(); mpu.initialize(); if (!mpu.testConnection()) { while (1); }

for (int toCzytanie = 0; toCzytanie < numReadings; toCzytanie++) { angleReadings[tenCzytanie] = 0; } }

pusta pętla () {

total = total - angleReadings[readIndex];

angleReadings[readIndex] = kąt; total = total + angleReadings[readIndex]; czytajIndeks = czytajIndeks + 1; if (readIndex >= numReadings) { readIndex = 0; }

if (gz > 30000) { Serial.println("Bang"); Kliknięcie myszką(); //Strzelaj, machając pistoletem do tyłu (uderzenie palcami) }

//accx, accy, accz;

mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); mpu.getAcceleration(&accx, &accy, &accz); //Serial.println(gy); // Serial.println(kąt);

stareZ = noweZ;

vx = (gx + 1000) / 150; vy = -(gz - 200) / 150; Mouse.move(vx, vy); opóźnienie(20);

Dit stukje code heeft een beetje uitleg nodig omdat je het waarschijnlijk een klein beetje moet aanpassen.

Wat er waarschijnlijk gaat gebeuren is dat je cursor uit zichzelf over je scherm gaat bewegen (van rechts naar links, van boven naar onder of diagonaal) en dit stukje code zorgt er voor dat je curor stil stil geeft je geeft als input als Je moet de values in in "gx + 1000" en "gz - 200" aanpassen totdat je het resultaat krijgt dat je wil en ik denk dat de values die wil nodig hebt afhankelijk zijn van je scherm resolutie. Als de cursor uit zichzelf van rechts naar links beweegd wil je "gx + x" aanpassen. Als de cursor uit zichzelf van boven naar onder beweegd wil je de "gz - x" aan passen. Als het diagonaal beweegd, dan kies je een van de twee wartości om aan te passen totdat hij nog maar over een as beweegd en dan pas je de andere aan.

Serial.print("gx = ");

Serial.print(gx); Serial.print(" | gz = "); Serial.print(gz); Serial.print(" | gy = "); Serial.println(gy); if (gx > 32000) { Serial.println("Przesuń w prawo"); //Przeładuj po przerzuceniu pistoletu w prawo Keyboard.write('r'); opóźnienie(250); } Serial.print("accx = "); Serial.print(accx); Serial.print(" | accy = "); Serial.print(accy); Serial.print(" | accz = "); Serial.println(accz); //roboczy //kąt = atan2((float) (ay - 16384), (float) (ax - 16384)) * (180,0 / PI) * -1; kąt = atan2((float) ay, (float) ~ax) * (180,0 / PI); //kąt zmiennoprzecinkowy = atan2((zmiennoprzecinkowe) ay, (zmiennoprzecinkowe) -ax) * (180,0 / PI); //Serial.println(średni kąt); }

Zalecana: