Inhaltsverzeichnis:

ITTT Rolando Ritzen - Motion Control Arcade Handschuh - Gunook
ITTT Rolando Ritzen - Motion Control Arcade Handschuh - Gunook

Video: ITTT Rolando Ritzen - Motion Control Arcade Handschuh - Gunook

Video: ITTT Rolando Ritzen - Motion Control Arcade Handschuh - Gunook
Video: When players lose control 🥊😳 2024, Juli
Anonim
ITTT Rolando Ritzen - Motion Control Arcade Handschuh
ITTT Rolando Ritzen - Motion Control Arcade Handschuh

Een handschoen die je kan gebruiken als Motion Controller für On-Rail-Shooter. De Gimmick van dit Projekt ist dat alles Motion Control ist, inclusief het schieten. (Je schiet door te "finger bangen")

Schritt 1: Het Material

Het materiaal dat je gaat nodig hebben ist vrij simpel. 1x Arduino Pro Micro von Arduino Leonardo1x MPU6050 Gyroskop

4x Kabel

Schritt 2: De Bekabeling

De Bekabeling
De Bekabeling

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

Schritt 3: Bibliotheken 1

Bibliotheken 1
Bibliotheken 1

Voor dit project heb je een paar benutzerdefinierte Bibliotheken nodig van deze link:

Laden Sie eine ZIP-Datei über den Knoten "Klonen oder herunterladen" rechts unten herunter.

Schritt 4: Bibliotheken 2

Bibliotheken 2
Bibliotheken 2

Öffnen Sie die Zip-Datei und klicken Sie auf die Karte "Arduino". En uit deze Arduino map wil je de mapjes "I2Cdev" und "MPU6050" pakken in je Arduino Bibliotheken (Programme > Arduino > Bibliotheken)

Schritt 5: De-Code

#enthalten

#einschließen #einschließen #einschließen #einschließen

MPU6050 mpu;

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

int16_t accx, accy, accz; int vx, vy; Schwimmwinkel;

// Code zum Glätten von inputint readIndex = 0; const int numReadings = 20; int angleReadings[numReadings]; int gesamt = 0; Float-Durchschnittswinkel = 0,0;

int altZ = 0;

int neuZ = 0;

Void setup () { Serial.begin (115200); Wire.begin(); Maus.begin(); mpu.initialize(); if (!mpu.testConnection()) { while (1); }

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

Leere Schleife () {

total = total - angleReadings[readIndex];

angleReadings[readIndex] = Winkel; total = total + angleReadings[readIndex]; readIndex = readIndex + 1; if (readIndex >= numReadings) { readIndex = 0; }

wenn (gz > 30000) {Serial.println ("Bang"); Mausklick(); // Schießen Sie, indem Sie die Waffe nach hinten schlagen (Finger schlagen)}

// accx, accy, accz;

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

altZ = neuZ;

vx = (gx + 1000) / 150; vy = –(gz – 200)/150; Mouse.move(vx, vy); Verzögerung (20);

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

Water 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 blijft staan as je geen input geeft. 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 pass. Als het diagonaal beweegd, dan kies je een van de twee values om aan te pass 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); wenn (gx > 32000) {Serial.println ("Nach rechts streichen"); // Nachladen, wenn die Waffe nach rechts bewegt wird Keyboard.write ('r'); Verzögerung (250); } Serial.print ("accx = "); Serial.print (acx); Serial.print(" | accy = "); Serial.print (accy); Serial.print(" | accz = "); Serial.println(accz); // arbeiten // Winkel = atan2 ((float) (ay - 16384), (float) (ax - 16384)) * (180.0 / PI) * -1; Winkel = atan2((float) ay, (float) ~ax) * (180,0 / PI); // Schwimmwinkel = atan2 ((float) ay, (float) -ax) * (180,0 / PI); //Seriell.println (Durchschnittswinkel); }

Empfohlen: