This project is an alternative controller for a rail-shooter, it is still in development, however it will shortly be finished. We had planned to make a controller for a horror video game with a heartbeat sensor, however a lot of the games were not compatible with Arduino and we had to change the reactions of the monsters ingame, so we switched into making a controller for Sniper Striker. The controller consists of a joystick to look in all angles, and a custom made 3D printed gun with two-three buttons, shoot,go forwards and go backwards. but these buttons are modifiable for all types of key actions, such as move forward/backwards or reload. We faced issues with the arduino code and also hardware defects, as it would randomly input letters when the breadboard was connected to any computer via USB and we face issues with cable management. All these problems and the change of project after week 3-4, it made us do something much less ambitious.
Files
Modeles 3D gun.zip
Final 3D models of the gun, as you can see it actually looks like a gun now.
x-zip-compressed -
601.10 kB -
12/20/2024 at 21:34
here is the actual final arduino code, we added some LEDs and sounds to mimic the effects of an actua sound, for example a sound when you're aiming and when you shoot a little light will turn on mimicking the muzzle flash of an actual gun.
#include <Mouse.h> #include "Keyboard.h"
// Joystick Pins int horzPin = A0; // Analog pin for horizontal joystick int vertPin = A1; // Analog pin for vertical joystick int selPin = 8; // Joystick button (select pin)
// Joystick Center Calibration int vertZero, horzZero; // Joystick center positions int vertValue, horzValue; // Joystick axis readings const float sensitivity = 0.3; // Adjust mouse sensitivity (lower = slower movement) int deadZone = 3; // Minimum offset to ignore small joystick movements
// Button Pin Assignments const int buttonWheelUp = 2; // Button for Mouse Wheel Up (Zoom) const int buttonWheelDown = 3; const int buttonMouseClick = 4; // Button for Left Mouse Click const int buzzerPin = 6; // Pin connected to the buzzer const int ledPin = 7; // Pin connected to the LED
// Apply Mouse Movement (inverted axes) if (scaledVertValue != 0) { // Move only if outside the dead zone Mouse.move(0, scaledVertValue); // Vertical movement (Y-axis) } if (scaledHorzValue != 0) { Mouse.move(scaledHorzValue, 0); // Horizontal movement (X-axis) }
We have made a few modifications to the code, here is the new version:
#include <Mouse.h> #include "Keyboard.h"
// Joystick Pins int horzPin = A0; // Analog pin for horizontal joystick int vertPin = A1; // Analog pin for vertical joystick int selPin = 8; // Joystick button (select pin)
// Joystick Center Calibration int vertZero, horzZero; // Joystick center positions int vertValue, horzValue; // Joystick axis readings const float sensitivity = 0.5; // Adjust mouse sensitivity (lower = slower movement) int deadZone = 10; // Minimum offset to ignore small joystick movements
// Button Pin Assignments const int buttonWheelUp = 2; // Button for Mouse Wheel Up (Zoom) const int buttonMouseClick = 3; // Button for Left Mouse Click
void setup() { Serial.begin(9600); // Start Serial Monitor for debugging // Joystick Setup pinMode(horzPin, INPUT); pinMode(vertPin, INPUT); pinMode(selPin, INPUT_PULLUP);
// Apply Mouse Movement (inverted axes) if (scaledVertValue != 0) { // Move only if outside the dead zone Mouse.move(0, scaledVertValue); // Vertical movement (Y-axis) } if (scaledHorzValue != 0) { Mouse.move(scaledHorzValue, 0); // Horizontal movement (X-axis) }
After trying to solve the code for multiple weeks, we changed the wiring as well, however that did not work but we have finally fixed the code so here it is, and the v2 gun is almost finished as well so here's the code:
#include <Mouse.h> #include "Keyboard.h"
int horzPin = A0; // Analog pin for horizontal joystick int vertPin = A1; // Analog pin for vertical joystick int selPin = 8; // Joystick button (select pin)
int vertZero, horzZero; // Stores joystick center values int vertValue, horzValue; // Stores joystick axis readings const float sensitivity = 200.0; // Sensitivity (float for precision) int mouseClickFlag = 0;
int invertMouse = -1; // Non-inverted movement
// Button pin assignments const int buttonW = 2; // Button for printing 'W' const int buttonS = 3; // Button for printing 'S' const int buttonMouseClick = 4; // Button for mouse left click
Our idea is to emulate the keys of a keyboard from buttons that are controlled by arduino. Problem is that it writing wtihout any input and deletes the codes. Here is the code:
We have encoutenred a bit of a problem, the games we had anticipated to modify, such as lehtal company, outlast and escape the backrooms, are not compatible with arduino, so we have scrapped that plan.
So our plan has changed now we're thinking of changing genres and going for a FPS.
Our main goal is to create a controller for a horror game, the idea is to pair a game with a heart sensor, a nosie detector 3 buttons, one for a lamp, one to interact and one for inventory and a joystick. Here is a quick draft of how it will look like.