Custom Handheld Arcade console with Raspberry Pi3
-
- Posts: 18
- Joined: Fri Jun 10, 2016 7:21 am
- Has thanked: 2 times
- Been thanked: 1 time
Re: Custom Handheld Arcade console with Raspberry Pi3
The project looks great! I was wondering how you were able to code the PSP analog stick?
- tronicgr
- Posts: 143
- Joined: Tue Jun 07, 2016 4:26 pm
- Has thanked: 95 times
- Been thanked: 67 times
- Contact:
Re: Custom Handheld Arcade console with Raspberry Pi3
Using the Teensy. Its emulating joystick and keyboard. See code below:steelnation248 wrote:The project looks great! I was wondering how you were able to code the PSP analog stick?
Code: Select all
/* Complete USB Joystick /keyboard Example
Teensy becomes a USB joystick with 11 buttons and 2 axis input
Button 12 is ESC keyboard, and button 13 is ENTER keyboard.
You must select Joystick and Keyboard from the "Tools > USB Type" menu
Pushbuttons should be connected between the digital pins and ground.
Potentiometers should be connected to analog inputs 0 to 5.
Analog joystick was PSP micro 2-axis
*/
#include <Bounce.h>
Bounce button9 = Bounce(12, 10);
Bounce button10 = Bounce(13, 10);
// Configure the number of buttons. Be careful not
// to use a pin for both a digital button and analog
// axis. The pullup resistor will interfere with
// the analog voltage.
const int numButtons = 12; // 16 for Teensy, 32 for Teensy++
void setup() {
// you can print to the serial monitor while the joystick is active!
Serial.begin(9600);
pinMode(12, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
// configure the joystick to manual send mode. This gives precise
// control over when the computer receives updates, but it does
// require you to manually call Joystick.send_now().
Joystick.useManualSend(true);
for (int i=0; i<numButtons; i++) {
pinMode(i, INPUT_PULLUP);
}
// Serial.println("Begin Complete Joystick Test");
}
byte allButtons[numButtons];
byte prevButtons[numButtons];
void loop() {
button9.update();
button10.update();
if (button9.fallingEdge()) {
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now(); // send the button press
Keyboard.set_key1(0);
Keyboard.send_now(); // send the button release
}
if (button10.fallingEdge()) {
Keyboard.set_key1(KEY_ESC);
Keyboard.send_now(); // send the button press
Keyboard.set_key1(0);
Keyboard.send_now(); // send the button release
}
// read 6 analog inputs and use them for the joystick axis
Joystick.X(map(analogRead(0),170, 853, 1023, 0));
Joystick.Y(map(analogRead(1),170, 853, 0, 1023));
// read digital pins and use them for the buttons
for (int i=0; i<numButtons; i++) {
if (digitalRead(i)) {
// when a pin reads high, the button is not pressed
// the pullup resistor creates the "on" signal
allButtons[i] = 0;
} else {
// when a pin reads low, the button is connecting to ground.
allButtons[i] = 1;
}
Joystick.button(i + 1, allButtons[i]);
}
Joystick.send_now();
}
Thanos
Re: Custom Handheld Arcade console with Raspberry Pi3
Thanks for sharing your build, I was thinking of an arcade build later on and now I know what I'll use as a psu, the SMAKN looks great, wish I had seen it sooner for my gameboy
-
- Posts: 18
- Joined: Fri Jun 10, 2016 7:21 am
- Has thanked: 2 times
- Been thanked: 1 time
Re: Custom Handheld Arcade console with Raspberry Pi3
Awesome! Do you happen to also have a picture or diagram of how you wired the PSP to the Teensy?tronicgr wrote:Using the Teensy. Its emulating joystick and keyboard. See code below:steelnation248 wrote:The project looks great! I was wondering how you were able to code the PSP analog stick?
ThanksCode: Select all
/* Complete USB Joystick /keyboard Example Teensy becomes a USB joystick with 11 buttons and 2 axis input Button 12 is ESC keyboard, and button 13 is ENTER keyboard. You must select Joystick and Keyboard from the "Tools > USB Type" menu Pushbuttons should be connected between the digital pins and ground. Potentiometers should be connected to analog inputs 0 to 5. Analog joystick was PSP micro 2-axis */ #include <Bounce.h> Bounce button9 = Bounce(12, 10); Bounce button10 = Bounce(13, 10); // Configure the number of buttons. Be careful not // to use a pin for both a digital button and analog // axis. The pullup resistor will interfere with // the analog voltage. const int numButtons = 12; // 16 for Teensy, 32 for Teensy++ void setup() { // you can print to the serial monitor while the joystick is active! Serial.begin(9600); pinMode(12, INPUT_PULLUP); pinMode(13, INPUT_PULLUP); // configure the joystick to manual send mode. This gives precise // control over when the computer receives updates, but it does // require you to manually call Joystick.send_now(). Joystick.useManualSend(true); for (int i=0; i<numButtons; i++) { pinMode(i, INPUT_PULLUP); } // Serial.println("Begin Complete Joystick Test"); } byte allButtons[numButtons]; byte prevButtons[numButtons]; void loop() { button9.update(); button10.update(); if (button9.fallingEdge()) { Keyboard.set_key1(KEY_ENTER); Keyboard.send_now(); // send the button press Keyboard.set_key1(0); Keyboard.send_now(); // send the button release } if (button10.fallingEdge()) { Keyboard.set_key1(KEY_ESC); Keyboard.send_now(); // send the button press Keyboard.set_key1(0); Keyboard.send_now(); // send the button release } // read 6 analog inputs and use them for the joystick axis Joystick.X(map(analogRead(0),170, 853, 1023, 0)); Joystick.Y(map(analogRead(1),170, 853, 0, 1023)); // read digital pins and use them for the buttons for (int i=0; i<numButtons; i++) { if (digitalRead(i)) { // when a pin reads high, the button is not pressed // the pullup resistor creates the "on" signal allButtons[i] = 0; } else { // when a pin reads low, the button is connecting to ground. allButtons[i] = 1; } Joystick.button(i + 1, allButtons[i]); } Joystick.send_now(); }
Thanos
Thanks man!
- tronicgr
- Posts: 143
- Joined: Tue Jun 07, 2016 4:26 pm
- Has thanked: 95 times
- Been thanked: 67 times
- Contact:
Re: Custom Handheld Arcade console with Raspberry Pi3
I don't have diagram, but I'll try to find a photo of the connections.steelnation248 wrote:Awesome! Do you happen to also have a picture or diagram of how you wired the PSP to the Teensy?tronicgr wrote:Using the Teensy. Its emulating joystick and keyboard. See code below:steelnation248 wrote:The project looks great! I was wondering how you were able to code the PSP analog stick?
ThanksCode: Select all
/* Complete USB Joystick /keyboard Example Teensy becomes a USB joystick with 11 buttons and 2 axis input Button 12 is ESC keyboard, and button 13 is ENTER keyboard. You must select Joystick and Keyboard from the "Tools > USB Type" menu Pushbuttons should be connected between the digital pins and ground. Potentiometers should be connected to analog inputs 0 to 5. Analog joystick was PSP micro 2-axis */ #include <Bounce.h> Bounce button9 = Bounce(12, 10); Bounce button10 = Bounce(13, 10); // Configure the number of buttons. Be careful not // to use a pin for both a digital button and analog // axis. The pullup resistor will interfere with // the analog voltage. const int numButtons = 12; // 16 for Teensy, 32 for Teensy++ void setup() { // you can print to the serial monitor while the joystick is active! Serial.begin(9600); pinMode(12, INPUT_PULLUP); pinMode(13, INPUT_PULLUP); // configure the joystick to manual send mode. This gives precise // control over when the computer receives updates, but it does // require you to manually call Joystick.send_now(). Joystick.useManualSend(true); for (int i=0; i<numButtons; i++) { pinMode(i, INPUT_PULLUP); } // Serial.println("Begin Complete Joystick Test"); } byte allButtons[numButtons]; byte prevButtons[numButtons]; void loop() { button9.update(); button10.update(); if (button9.fallingEdge()) { Keyboard.set_key1(KEY_ENTER); Keyboard.send_now(); // send the button press Keyboard.set_key1(0); Keyboard.send_now(); // send the button release } if (button10.fallingEdge()) { Keyboard.set_key1(KEY_ESC); Keyboard.send_now(); // send the button press Keyboard.set_key1(0); Keyboard.send_now(); // send the button release } // read 6 analog inputs and use them for the joystick axis Joystick.X(map(analogRead(0),170, 853, 1023, 0)); Joystick.Y(map(analogRead(1),170, 853, 0, 1023)); // read digital pins and use them for the buttons for (int i=0; i<numButtons; i++) { if (digitalRead(i)) { // when a pin reads high, the button is not pressed // the pullup resistor creates the "on" signal allButtons[i] = 0; } else { // when a pin reads low, the button is connecting to ground. allButtons[i] = 1; } Joystick.button(i + 1, allButtons[i]); } Joystick.send_now(); }
Thanos
Thanks man!
I used the recommended connection method mentioned on the teensy official page for teensyduino.
*Edit: found a photo: red is 5v black is ground.
Thanks
Thanos
-
- Posts: 18
- Joined: Fri Jun 10, 2016 7:21 am
- Has thanked: 2 times
- Been thanked: 1 time
Re: Custom Handheld Arcade console with Raspberry Pi3
Awesome! Thank you again.tronicgr wrote:
I don't have diagram, but I'll try to find a photo of the connections.
I used the recommended connection method mentioned on the teensy official page for teensyduino.
*Edit: found a photo: red is 5v black is ground.
IMG_20160610_152753.jpg
Thanks
Thanos
Who is online
Users browsing this forum: No registered users and 1 guest