Table of Contents

Game Controller

Introduction

I always liked playing video games and table tennis so I decided to merge those two into this Project:)

Descriere generală

In this instructable session we are going to how to make a game controller for PC by using arduino nano ble 33 sense . with out using any other peripherial I used the onboard proximity sensor and python for the controlling the games.

Hardware Design

bobinpoza1.jpg List of components:Arduino Nano Ble Sense, USB Cable Assembly, USB Type A Plug to Micro USB Type B Plug

Software Design

#include <Arduino_APDS9960.h>

void setup() {
  Serial.begin(9600);
  while (!Serial);

  if (!APDS.begin()) {
    Serial.println("Error initializing APDS9960 sensor!");
  }
}

void loop() {
  // check if a proximity reading is available
  if (APDS.proximityAvailable()) {
    // read the proximity
    // - 0   => close
    // - 255 => far
    // - -1  => error
    int proximity = APDS.readProximity();
    if (proximity==0){
         Serial.println('d');
      
    }

    // print value to the Serial Monitor
 
  }

  // wait a bit before reading again
  delay(100);
   } 
import serial
from pynput.keyboard import Key, Controller
ser = serial.Serial('COM5', 9600)
keyboard = Controller()
while True:
    data = ser.readline()
    
    if data.decode().strip() == "d":
        keyboard.press("d")
        keyboard.release("d")

I used just the <Arduino_APDS9960.h> Library for the Arduino Nano BLE 33 Sense

Rezultate Obţinute

For the final result I could use this project as a Game Controller for playing Timing Games.

Bibliografie/Resurse

Export to PDF