PRABEEN RAJ
Published © GPL3+

Arduino Nano BLE 33 Sense Game Controller

I made this game controller by using Arduino Nano BLE 33 Sense which has onboard proximity sensor.

BeginnerFull instructions provided4,970
Arduino Nano BLE 33 Sense Game Controller

Things used in this project

Hardware components

Arduino Nano 33 BLE Sense
Arduino Nano 33 BLE Sense
×1
USB Cable Assembly, USB Type A Plug to Micro USB Type B Plug
USB Cable Assembly, USB Type A Plug to Micro USB Type B Plug
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Arduino Code

C/C++
#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);
}

Python Code

Python
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")

Game Controler Code

Credits

PRABEEN RAJ

PRABEEN RAJ

10 projects • 2 followers

Comments