Arnov SharmaElektro Punkz
Published © MIT

Arduino Game Controller

DIY game controller project with a Pro Micro which uses an ATmega32U4 microcontroller for emulating a game controller.

IntermediateFull instructions provided2 hours21,325

Things used in this project

Hardware components

Pro Micro - 5V/16MHz
SparkFun Pro Micro - 5V/16MHz
×1
Arduino Leonardo
Arduino Leonardo
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×12
Resistor 10k ohm
Resistor 10k ohm
×1
Custom Etched PCB
×1
UTSOURCE Electronic Parts
UTSOURCE Electronic Parts
×1

Software apps and online services

Arduino IDE
Arduino IDE
Fusion
Autodesk Fusion

Hand tools and fabrication machines

Ferrous chloride powder
3D Printer (generic)
3D Printer (generic)
Drill / Driver, Cordless
Drill / Driver, Cordless

Story

Read more

Custom parts and enclosures

PCB Encloser

Schematics

sch

PCB Layout PDF

Code

CODE

C/C++
#include <Keyboard.h>

int WPin = 2;  // UP   
int SPin = 3;  // DOWN
int APin = 4; //LEFT 
int DPin = 5; //RIGHT
int UPLpin = 7; //upper left Q
int UPRpin = 9; //upper right
int Xpin = 14;//x
int Apin = 10; //i
int Ypin = 15;//y
int Bpin = 16;//b




void setup()
{
  pinMode(WPin, INPUT); 
  pinMode(SPin, INPUT);
  pinMode(APin, INPUT);
  pinMode(DPin, INPUT);
  pinMode(UPLpin, INPUT);
  pinMode(UPRpin, INPUT);
  pinMode(Xpin, INPUT);
  pinMode(Apin, INPUT);
  pinMode(Ypin, INPUT);
  pinMode(Bpin, INPUT);
  
  digitalWrite(WPin, HIGH);  
  digitalWrite(SPin, HIGH);
  digitalWrite(APin, HIGH);
  digitalWrite(DPin, HIGH);
  digitalWrite(UPLpin, HIGH);
  digitalWrite(UPRpin, HIGH);
  digitalWrite(Xpin, HIGH);
  digitalWrite(Apin, HIGH);
  digitalWrite(Ypin, HIGH);
  digitalWrite(Bpin, HIGH);

  Keyboard.begin();
  
}

void loop()
{
  if (digitalRead(WPin) == 0) 
  {
    Keyboard.write('W');  
    delayMicroseconds(1); 
  }
  if (digitalRead(SPin) == 0) 
  {
    Keyboard.write('S'); 
    delayMicroseconds(1);  
  }
  if (digitalRead(APin) == 0)  
  {
    Keyboard.write('A'); 
    delayMicroseconds(1);  
  }
  if (digitalRead(DPin) == 0)  
  {
    Keyboard.write('D'); 
    delayMicroseconds(1);  
  }
  if (digitalRead(UPLpin) == 0)  
  {
    Keyboard.write('q'); 
    delayMicroseconds(1); 
  }
  if (digitalRead(UPRpin) == 0)  
  {
    Keyboard.write('e'); 
    delayMicroseconds(1);  
  }
    if (digitalRead(Xpin) == 0)  
  {
    Keyboard.write('x'); 
    delayMicroseconds(1);  
  }
  if (digitalRead(Apin) == 0)  
  {
    Keyboard.write('i'); 
    delayMicroseconds(1);  
  }
  if (digitalRead(Ypin) == 0)  
  {
    Keyboard.write('y'); 
    delayMicroseconds(1);  
  }
  if (digitalRead(Bpin) == 0)  
  {
    Keyboard.write('b'); 
    delayMicroseconds(1);  
  }
}  
  

Credits

Arnov Sharma

Arnov Sharma

306 projects • 306 followers
Just your average MAKER
Elektro Punkz

Elektro Punkz

2 projects • 9 followers
"EleKtroPunkz Research Society"

Comments