Taula de continguts:

ITTT Rolando Ritzen - Guant Arcade Motion Control: 5 passos
ITTT Rolando Ritzen - Guant Arcade Motion Control: 5 passos

Vídeo: ITTT Rolando Ritzen - Guant Arcade Motion Control: 5 passos

Vídeo: ITTT Rolando Ritzen - Guant Arcade Motion Control: 5 passos
Vídeo: A Bob Velseb Dating Sim - Fappable Cannibal DEMO 2024, Juliol
Anonim
ITTT Rolando Ritzen - Guant Arcade Motion Control
ITTT Rolando Ritzen - Guant Arcade Motion Control

Een handschoen die je kan gebruiken als motion controller for on-rail shooters. El projecte del seu truc és tot el control del moviment, inclòs el programa. (Je schiet door te "finger bangen")

Pas 1: Het Materiaal

Het materiaal dat je gaat nodig hebben is vrij simpel. 1x Arduino pro micro d’Arduino Leonardo 1x giroscopi MPU6050

4x kabels

Pas 2: De Bekabeling

De Bekabeling
De Bekabeling

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

Pas 3: biblioteques 1

Biblioteques 1
Biblioteques 1

Per a aquest projecte heb je een paar custom libraries nodig van deze link:

Descarregueu el fitxer ZIP mitjançant el botó "Clona o descarregueu".

Pas 4: biblioteques 2

Biblioteques 2
Biblioteques 2

Obriu el fitxer Zip en feu clic al mapa "Arduino". En uit deze Arduino map will be de mapjes "I2Cdev" en "MPU6050" pakken en in Arduino libraries zetten (Program Files> Arduino> libraries)

Pas 5: De Code

#incloure

#include #include #include #include

MPU6050 mpu;

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

int16_t accx, accy, accz; int vx, vy; angle de flotació;

// codi per suavitzar inputint readIndex = 0; const int numLectures = 20; int angleLectures [numLectures]; int total = 0; float averageAngle = 0,0;

int oldZ = 0;

int newZ = 0;

configuració nul·la () {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 buit () {

total = total - angleReadings [readIndex];

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

if (gz> 30000) {Serial.println ("Bang"); Mouse.click (); // Dispara fent girar la pistola cap enrere (cop de dit)}

// accx, accy, accz;

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

oldZ = newZ;

vx = (gx + 1000) / 150; vy = - (gz - 200) / 150; Mouse.move (vx, vy); retard (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 screen 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 jeen 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 screen 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 values 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 ("Flick Right"); // Torneu a carregar quan llanceu la pistola cap a la dreta Keyboard.write ('r'); retard (250); } Serial.print ("accx ="); Serial.print (accx); Serial.print ("| accy ="); Serial.print (accy); Serial.print ("| accz ="); Serial.println (accz); // treballant // angle = atan2 ((float) (ay - 16384), (float) (ax - 16384)) * (180.0 / PI) * -1; angle = atan2 ((float) ay, (float) ~ ax) * (180.0 / PI); // float angle = atan2 ((float) ay, (float) -ax) * (180.0 / PI); //Serial.println(averageAngle); }

Recomanat: