Tabla de contenido:

ITTT Rolando Ritzen - Guante Motion Control Arcade: 5 pasos
ITTT Rolando Ritzen - Guante Motion Control Arcade: 5 pasos

Video: ITTT Rolando Ritzen - Guante Motion Control Arcade: 5 pasos

Video: ITTT Rolando Ritzen - Guante Motion Control Arcade: 5 pasos
Video: Trial by Firelight | Critical Role | Campaign 3, Episode 2 2024, Mes de julio
Anonim
ITTT Rolando Ritzen - Guante Motion Control Arcade
ITTT Rolando Ritzen - Guante Motion Control Arcade

Een handschoen die je kan gebruiken como controlador de movimiento para tiradores en riel. El proyecto de gimmick van dit es el control de movimiento de todos los elementos, inclusive het schieten. (Je schiet door te "finger bangen")

Paso 1: Het Materiaal

Het material dat je gaat nodig hebben es vrij simpel. 1x Arduino pro micro de Arduino Leonardo 1x giroscopio MPU6050

4x kabels

Paso 2: De Bekabeling

De Bekabeling
De Bekabeling

Zoals je in het schema in de afbeelding ziet es de bekabeling super simpel. MPU VCC> Arduino VCCMPU tierra> Arduino tierraMPU SCL> Pin 3MPU SDA> Pin 2

Paso 3: Bibliotecas 1

Bibliotecas 1
Bibliotecas 1

Voor dit project heb je een paar bibliotecas personalizadas nodig van deze enlace:

Descargue un archivo ZIP a través de "Clonar o descargar" knop rechts bovenaan.

Paso 4: Bibliotecas 2

Bibliotecas 2
Bibliotecas 2

Abra el archivo Zip y haga clic en el mapa "Arduino". En uit deze Arduino map wil je de mapjes "I2Cdev" en "MPU6050" pakken in je Arduino libraries zetten (Archivos de programa> Arduino> bibliotecas)

Paso 5: De Code

#incluir

#incluir #incluir #incluir #incluir

MPU6050 mpu;

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

int16_t accx, accy, accz; int vx, vy; ángulo de flotación;

// código para suavizar inputint readIndex = 0; const int numReadings = 20; int angleReadings [numReadings]; int total = 0; flotador averageAngle = 0.0;

int oldZ = 0;

int newZ = 0;

configuración vacía () {Serial.begin (115200); Wire.begin (); Mouse.begin (); mpu.initialize (); if (! mpu.testConnection ()) {while (1); }

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

bucle vacío () {

total = total - angleReadings [readIndex];

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

if (gz> 30000) {Serial.println ("Bang"); Click del raton(); // Dispara moviendo el arma hacia atrás (golpe con los dedos)}

// accx, accy, accz;

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

oldZ = newZ;

vx = (gx + 1000) / 150; vy = - (gz - 200) / 150; Mouse.move (vx, vy); retraso (20);

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

Wat er waarschijnlijk gaat gebeuren es dat je cursor uit zichzelf sobre 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 als 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 atten. Als het diagonaal beweegd, dan kies je een van de twee valora om aan te pasa totdat hij nog maar sobre 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 ("Desplazar hacia la derecha"); // Recargar al mover el arma hacia la derecha Keyboard.write ('r'); retraso (250); } Serial.print ("accx ="); Serial.print (accx); Serial.print ("| accy ="); Serial.print (accy); Serial.print ("| accz ="); Serial.println (accz); // trabajando // ángulo = atan2 ((float) (ay - 16384), (float) (ax - 16384)) * (180.0 / PI) * -1; ángulo = atan2 ((flotar) ay, (flotar) ~ ax) * (180.0 / PI); // ángulo de flotación = atan2 ((float) ay, (float) -ax) * (180.0 / PI); //Serial.println(averageAngle); }

Recomendado: