Go Down

Topic: Arduino Uno Gamepad (Input to Game) (Read 873 times) previous topic - next topic

MonsterBlock43

Hello,

I've wanted to realize a Gamepad with a Arduino Uno Rev. 3
I have bought some Buttons and connected it to my Arduino.

With this short code i can put the signal from 0 to 1.

void setup(){
   Serial.begin(9600);
   pinMode(2,INPUT);
}

void loop(){
   int buttonstatus;
   buttonstatus = digitalRead(2);
   Serial.println(buttonstatus,DEC);
}

Now my Question is, how to use this signal for a game. So that i can press the Button and the game realise that i press it. It should work the same like a keyboard.

Please help me :)
Thank you very much,
Mario

HazardsMind

#1
Feb 11, 2013, 02:22 pm Last Edit: Feb 11, 2013, 02:25 pm by HazardsMind Reason: 1
Quote
It should work the same like a keyboard.

Question, is this going to be a controller for a computer, or an actual gaming console?

Look at the keyboard example provided in the playground and maybe gamepads and joysticks.
NOTE: Only works with Arduino Leonardo!
http://playground.arduino.cc//Main/InterfacingWithHardware#joygame

My GitHub:
https://github.com/AndrewMascolo?tab=repositories

MonsterBlock43

It will be controlled by a computer.
So what i need is a Arduino Leonardo and set the Inputs as keyboard signals?

Thanks :)
Mario

HazardsMind

#3
Feb 11, 2013, 02:45 pm Last Edit: Feb 11, 2013, 02:48 pm by HazardsMind Reason: 1
Quote
It will be controlled by a computer.

So wait, are you building a controller to control a computer or use the computer as a controller to control a console?
It is two different things then. If you control a computer, then you would use the keyboard library with a Leonardo. BUT, if you want to trick a console to think the arduino is a controller, it is much different.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

Go Up