Sommario:

ITTT Rolando Ritzen - Guanto Motion Control Arcade: 5 passaggi
ITTT Rolando Ritzen - Guanto Motion Control Arcade: 5 passaggi

Video: ITTT Rolando Ritzen - Guanto Motion Control Arcade: 5 passaggi

Video: ITTT Rolando Ritzen - Guanto Motion Control Arcade: 5 passaggi
Video: Crisis of Faith | Critical Role | Campaign 3, Episode 61 2024, Luglio
Anonim
ITTT Rolando Ritzen - Guanto Motion Control Arcade
ITTT Rolando Ritzen - Guanto Motion Control Arcade

È possibile utilizzare un controller di movimento per gli sparatutto su rotaia. L'espediente del progetto è tutto ciò che è il controllo del movimento, inclusi gli schietti. (Je schiet door te "finger bangen")

Passaggio 1: Het Materiaal

Het materialeal dat je gaat nodig hebben is vrij simpel. 1x Arduino pro micro di Arduino Leonardo1x giroscopio MPU6050

4x cavi

Fase 2: De Bekabeling

De Bekabeling
De Bekabeling

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

Passaggio 3: Librerie 1

Librerie 1
Librerie 1

Per qualsiasi progetto heb je een paar custom library nodig van deze link:

Scarica un file ZIP tramite il pulsante "Clone or download" rechts bovenaan.

Passaggio 4: Librerie 2

Biblioteche 2
Biblioteche 2

Apri il file zip e clicca sulla mappa "Arduino". En uit deze Arduino map wil je de mapjes "I2Cdev" en "MPU6050" pakken en in je Arduino library zetten (Programmi > Arduino > librerie)

Passaggio 5: codifica del codice

#includere

#include #include #include #include

MPU6050 MPU;

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

int16_t accx, accy, accz; int vx, vy; angolo di flottazione;

//codice per livellare inputint readIndex = 0; const int numLetture = 20; int angoloLetture[numLetture]; int totale = 0; float medioAngolo = 0.0;

int oldZ = 0;

int nuovaZ = 0;

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

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

ciclo vuoto() {

totale = totale - angleReadings[readIndex];

angleReadings[readIndex] = angolo; totale = totale + letture angolo[readIndex]; readIndex = readIndex + 1; if (readIndex >= numReadings) { readIndex = 0; }

if (gz > 30000) { Serial.println("Bang"); Mouse.click(); //Spara muovendo la pistola all'indietro (sbattendo le dita) }

//accx, accy, accz;

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

vecchiaZ = nuovaZ;

vx = (gx + 1000) / 150; vy = -(gz - 200) / 150; Mouse.move(vx, vy); ritardo(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 sblijeft input 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 relutie. Als de cursor uit zichzelf van rechts naar links beweegd wil je "gx + x" aanpassen. Als de cursor uit zichzelf van boven naar beweegd wil je de "gz - x" aan passen. Als het diagonaal beweegd, dan kies je een van de twee valori 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("Scorri verso destra"); //Ricarica quando muovi la pistola a destra Keyboard.write('r'); ritardo(250); } Serial.print("accx = "); Serial.print(accx); Serial.print(" | acci = "); Serial.print(accy); Serial.print(" | accz = "); Serial.println(accz); //lavoro //angolo = atan2((float) (ay - 16384), (float) (ax - 16384)) * (180.0 / PI) * -1; angolo = atan2((float) ay, (float) ~ax) * (180.0 / PI); //float angle = atan2((float) ay, (float) -ax) * (180.0 / PI); //Serial.println(averageAngle); }

Consigliato: