Table des matières:

ITTT Rolando Ritzen - Gant d'arcade Motion Control : 5 étapes
ITTT Rolando Ritzen - Gant d'arcade Motion Control : 5 étapes

Vidéo: ITTT Rolando Ritzen - Gant d'arcade Motion Control : 5 étapes

Vidéo: ITTT Rolando Ritzen - Gant d'arcade Motion Control : 5 étapes
Vidéo: Книга 07 — Аудиокнига Виктора Гюго «Горбун из Нотр-Дама» (главы 1–8) 2024, Juillet
Anonim
ITTT Rolando Ritzen - Gant d'arcade Motion Control
ITTT Rolando Ritzen - Gant d'arcade Motion Control

Een handschoen 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 porte te "finger bangen")

Étape 1: Het matériel

Het materiaal dat je gaat nodig hebben is vrij simpel. 1x Arduino pro micro d'Arduino Leonardo1x gyroscope MPU6050

4x câbles

Étape 2: De Bekabeling

De Bekabeling
De Bekabeling

Zoals je in het schema in de afbeelding ziet est de bekabeling super simpel. MPU VCC > masse Arduino VCCMPU > masse ArduinoMPU SCL > broche 3MPU SDA > broche 2

Étape 3: Bibliothèques 1

Bibliothèques 1
Bibliothèques 1

Voor dit project heb je een paar bibliothèques personnalisées lien nodig van deze:

Téléchargez un fichier ZIP via de "Cloner ou télécharger" knop rechts bovenaan.

Étape 4: Bibliothèques 2

Bibliothèques 2
Bibliothèques 2

Ouvrez le fichier Zip en klik op het mapje "Arduino". En uit deze Arduino map wil je de mapjes "I2Cdev" en "MPU6050" pakken en in je Arduino library zetten (Program Files > Arduino > library)

Étape 5: Décoder

#comprendre

#include #include #include #include

MPU6050 mpu;

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

int16_t accx, accy, accz; int vx, vy; angle de flottement;

//code de lissage inputint readIndex = 0; const int numLectures = 20; int angleReadings[numReadings]; entier = 0; float moyenAngle = 0,0;

int ancienZ = 0;

int nouveauZ = 0;

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

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

boucle vide() {

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"); Clic de souris(); //Tire en faisant reculer le pistolet (coup de doigt) }

//accx, accy, accz;

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

ancienZ = nouveauZ;

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 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 input alsge jeftgeen 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 resolutie. Als de cursor uit zichzelf van rechts naar links beweegd wil je "gx + x" aanpassen. Als of 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 valeurs 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); if (gx > 32000) { Serial.println("Flick Right"); //Recharger en déplaçant le pistolet vers la droite Keyboard.write('r'); retard (250); } Serial.print("accx = "); Serial.print(accx); Serial.print(" | accy = "); Serial.print(accy); Serial.print(" | accz = "); Serial.println(accz); //travail //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); //Série.println(angle moyen); }

Conseillé: