amiga-news DEUTSCHE VERSION
.
Links| Forums| Comments| Report news
.
Chat| Polls| Newsticker| Archive
.

[Login] [Register] [Forgot your password??]

< Next messagePrior message >
09.Mar.2019



Construction manual: Connecting Amiga joysticks via USB to the PC
Using an Arduino board of the type Pro Micro the Dutch Amiga fan Martijn has constructed an adapter for connecting two Atari/Commodore joysticks to current computers via USB. His solution emulates an USB joystick and therefore should work without any additional driver.

Since the microcontroller board already is equipped with an USB port and sufficient digital input and output ports, soldering operations are restricted to connecting some ports on the controller with the joystick ports. The hobbyist also provides a control program which is compiled by the Arduino IDE and then transferred to the adapter. The first picture shows his adapter in action:


Martijn has used an old 25-pin Sub-D connector for hosting his adapter - the middle pins were removed for they are not required. In this way the complete switch could be hosted in the connector but you can also use two 9-pin Sub-D connectors:


On the next picture you can see the internal wiring. If you are going to recreate the adapter then youu have to connect the required pins on the joystick port to any digital input/output ports on the Arduino.


Finally there is the control program written by Martijn which interprets the joystick movements and sends corresponding joystick results via USB to the computer. It is important that the query of the digital input ports - "digitalread(n)", "n" standing for the number of the queried port - corresponds with the wiring. Maybe the queries in the control program have to be adapted.

The program is transferred via Arduino IDE to the microcontroller board. For compiling it the Arduino Joystick Library is required.

#include <Joystick2.h>

void setup() {
for (int i = 5; i<=9; i++) {
pinMode(i, INPUT_PULLUP);
}
pinMode(10, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
pinMode(15, INPUT_PULLUP);
pinMode(18, INPUT_PULLUP);
Joystick[0].begin(true);
Joystick[1].begin(true);
}

void loop() {
// joystick 1 as HID joystick

if (digitalRead(6) == 0) {
// up
Joystick[0].setYAxis(-127);
} else if (digitalRead(7) == 0) {
// down
Joystick[0].setYAxis(127);
} else {
Joystick[0].setYAxis(0);
}

if (digitalRead(8) == 0) {
// left
Joystick[0].setXAxis(-127);
} else if (digitalRead(9) == 0) {
// right
Joystick[0].setXAxis(127);
} else {
Joystick[0].setXAxis(0);
}

if (digitalRead(5) == 0) {
Joystick[0].pressButton(0);
} else {
Joystick[0].releaseButton(0);
}


// joystick 2 as HID joystick
if (digitalRead(14) == 0) {
// up
Joystick[1].setYAxis(-127);
} else if (digitalRead(16) == 0) {
// down
Joystick[1].setYAxis(127);
} else {
Joystick[1].setYAxis(0);
}

if (digitalRead(15) == 0) {
// left
Joystick[1].setXAxis(-127);
} else if (digitalRead(18) == 0) {
// right
Joystick[1].setXAxis(127);
} else {
Joystick[1].setXAxis(0);
}

if (digitalRead(10) == 0) {
Joystick[1].pressButton(0);
} else {
Joystick[1].releaseButton(0);
}
}
(cg) (Translation: dr)

[News message: 09. Mar. 2019, 02:03] [Comments: 0]
[Send via e-mail]  [Print version]  [ASCII version]
< Next messagePrior message >

.
Masthead | Privacy policy | Netiquette | Advertising | Contact
Copyright © 1997-2019 by amiga-news.de - all rights reserved.
.