Megadrive pad Arduino uno Code via Unojoy
hi everyone,
i tried out few codes found on net nothing seems work (for me).
either have buttons in state or (high: start /low b c) not together.
every pin of db9 pad in digital inputof uno (except pin 0 & 1)
pin 5:+5v
pin 8: ground
pin 7 select button (as output).
anyone have idea ?
thanks
i tried out few codes found on net nothing seems work (for me).
either have buttons in state or (high: start /low b c) not together.
every pin of db9 pad in digital inputof uno (except pin 0 & 1)
pin 5:+5v
pin 8: ground
pin 7 select button (as output).
anyone have idea ?
thanks
ok found out !
i used code :
i used code :
code: [select]
[#include "unojoy.h"
int = 2;
int down = 3;
int left = 4;
int right = 5;
int ab = 6;
int slct = 7; //setting pin high/low reads a/b , start/c
int startc = 8;
void setup() {
(int = 2; <= 6; += 1){
pinmode(i, input);
} //pins 1-6 inputs
pinmode(slct, output); //'select' pin output
pinmode(startc, input);
setupunojoy();
}
void loop() {
dataforcontroller_t controllerdata = getcontrollerdata();
setcontrollerdata(controllerdata); //unojoy loop taken example sketch
}
dataforcontroller_t getcontrollerdata(void) {
dataforcontroller_t controllerdata = getblankdataforcontroller();
digitalwrite(slct, low); //set 'select' low read , start
controllerdata.squareon = !digitalread(ab); //uj data inverse of pad data
if (digitalread(startc) == low && digitalread(up) == low) {
controllerdata.homeon = high; //start , home button
}
else {
controllerdata.homeon = low;
controllerdata.dpadupon = !digitalread(up);
controllerdata.starton = !digitalread(startc);
}
if (digitalread(startc) == low && digitalread(down) == low) {
controllerdata.selecton = high; //start , down select button
}
else {
controllerdata.selecton = low;
controllerdata.dpaddownon = !digitalread(down);
}
digitalwrite(slct, high); //set 'select' high read b , c
controllerdata.dpadlefton = !digitalread(left);
controllerdata.dpadrighton = !digitalread(right);
controllerdata.crosson = !digitalread(ab);
controllerdata.circleon = !digitalread(startc);
return controllerdata;
} /code]
but have create unojoy folder containing unojoy.h in library folder follows:
\mydocs\arduino\libraries\unojoy\unojoy.h
next configure inputs in emulator(i personnaly prefer kega fusion: great video , sound options) , you're ready go !
good retro gaming ;)
Arduino Forum > Using Arduino > Programming Questions > Megadrive pad Arduino uno Code via Unojoy
arduino
Comments
Post a Comment