The NEW Build Your Own Arcade Controls
Main => Software Forum => Topic started by: abispac on January 19, 2019, 01:40:52 pm
-
so wondering around the internet i found that some folks at MFME forums have managed to use an arduino mega as an ipac and it seems to work like a charm, them some dude named eric claimed he used all the time with mame. im trying to set this up and it works just fine.
code for using arduino on mamehooker is simple:
void setup() {
Serial.begin(9600);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(54, INPUT);
pinMode(55, OUTPUT);
}
void loop() {
while (Serial.available() > 0) {
int pin = Serial.parseInt();
int value = Serial.parseInt();
if (Serial.read() == 'x') {
digitalWrite(pin, value);
Serial.println();
}
}
}
now after that i just modify the rom ini with something like
[General]
MameStart=cmo 4 baud=9600_parity=N_data=8_stop=1
MameStop=cmc 4
StateChange=
OnRotate=
OnPause=
[KeyStates]
RefreshTime=
[Output]
lamp1=cmw 4 2., cmw 4 %s%, cmw 4 x
lamp2=cmw 4 3., cmw 4 %s%, cmw 4 x
lamp3=cmw 4 4., cmw 4 %s%, cmw 4 x
lamp4=cmw 4 5., cmw 4 %s%, cmw 4 x
lamp5=cmw 4 6., cmw 4 %s%, cmw 4 x
lamp8=cmw 4 9., cmw 4 %s%, cmw 4 x
lamp6=cmw 4 7., cmw 4 %s%, cmw 4 x
lamp0=
lamp9=cmw 4 10., cmw 4 %s%, cmw 4 x
lamp12=cmw 4 13., cmw 4 %s%, cmw 4 x
lamp7=cmw 4 8., cmw 4 %s%, cmw 4 x
lamp10=cmw 4 11., cmw 4 %s%, cmw 4 x
lamp11=cmw 4 12., cmw 4 %s%, cmw 4 x
lamp13=cmw 4 13., cmw 4 %s%, cmw 4 x
lamps work like a charm.
I just need help with one thing i can not figure out,the hopper, i would like the output 55 to be the hopper trigger so on pin 55 should stay on, not flashing until input 54 wich is the sensor sends a number of pulses, anyway heres the code hope someone can help me out. thanks
-
Well are there a fixed number of pulses (1-9 or whatever)? You just need to send multiple commands for each state slot, turning the appropriate output off, waiting (there's a command for that) and then turning it back on again. You should be able to figure that out via the drop down menus for adding commands within the app.
-
You should be able to figure that out via the drop down menus for adding commands within the app.
:laugh2: cmon man , make it easy for me :laugh2: but you right, im a test and fail and hopefully succeed and post result. thanks man
-
Well are there a fixed number of pulses (1-9 or whatever)? You just need to send multiple commands for each state slot, turning the appropriate output off, waiting (there's a command for that) and then turning it back on again. You should be able to figure that out via the drop down menus for adding commands within the app.
i sent you a pm. :)
-
I use mamehooker with an Arduino. It works well. Here I’m reading Neo Geo outputs to do credit LEDs and marquees.
https://youtu.be/PkgI7bxyync (https://youtu.be/PkgI7bxyync)
This is the Neo cab I made with the Arduino inside.
https://youtu.be/lp00N5eoVbo (https://youtu.be/lp00N5eoVbo)
Incase it helps, all my code is here in a build log:
https://forum.arcadeotaku.com/viewtopic.php?f=6&t=35743 (https://forum.arcadeotaku.com/viewtopic.php?f=6&t=35743)
Reading outputs from Mame on a Pi is fairly straightforward too.
https://youtu.be/1UVK74FLJp4 (https://youtu.be/1UVK74FLJp4)
... the Pi is under the screen.
This was based on a great bit of code I found in github which you may find useful:
https://github.com/arfink/ (https://github.com/arfink/)
You don’t need an Arduino at all... just control the Pi pins from Mame!
https://youtu.be/3DqgnqqnZ9A (https://youtu.be/3DqgnqqnZ9A)
8)
-
thanks for the info, i will take a look, im not planing on using a pi just the arduino, hope i can finish my proyect.
I use mamehooker with an Arduino. It works well. Here I’m reading Neo Geo outputs to do credit LEDs and marquees.
https://youtu.be/PkgI7bxyync (https://youtu.be/PkgI7bxyync)
This is the Neo cab I made with the Arduino inside.
https://youtu.be/lp00N5eoVbo (https://youtu.be/lp00N5eoVbo)
Incase it helps, all my code is here in a build log:
https://forum.arcadeotaku.com/viewtopic.php?f=6&t=35743 (https://forum.arcadeotaku.com/viewtopic.php?f=6&t=35743)
Reading outputs from Mame on a Pi is fairly straightforward too.
https://youtu.be/1UVK74FLJp4 (https://youtu.be/1UVK74FLJp4)
... the Pi is under the screen.
This was based on a great bit of code I found in github which you may find useful:
https://github.com/arfink/ (https://github.com/arfink/)
You don’t need an Arduino at all... just control the Pi pins from Mame!
https://youtu.be/3DqgnqqnZ9A (https://youtu.be/3DqgnqqnZ9A)
8)
-
I made some testing too, some month ago :)
Abispac's code resembles mine (which in turn resembles that of others...)
https://youtu.be/V5D2I7cC_1A
-
I made some testing too, some month ago :)
Abispac's code resembles mine (which in turn resembles that of others...)
https://youtu.be/V5D2I7cC_1A
well, led outputs are easy, i dont have a problem with that , is just the hopper that dont work right.
-
At the moment your arduino code looks for an 'x', then turns on/off the pin (lamp) that it just read over serial.
If mame has a hopper output (you'd need to check), then maybe suffix that output with 'y' in the ini file... then, with "if (Serial.read() == 'y')" you can do something else other than light up a lamp.
Check out my example if it helps. I read in 3 digits and treat them all differently. One is a 'tens' digit for the credit display, one is a 'units' for the credit display... and the 3rd indicates which marquee to light up.
I've not done it the most efficient way at all, but muddled through and it works well.
-
At the moment your arduino code looks for an 'x', then turns on/off the pin (lamp) that it just read over serial.
If mame has a hopper output (you'd need to check), then maybe suffix that output with 'y' in the ini file... then, with "if (Serial.read() == 'y')" you can do something else other than light up a lamp.
Check out my example if it helps. I read in 3 digits and treat them all differently. One is a 'tens' digit for the credit display, one is a 'units' for the credit display... and the 3rd indicates which marquee to light up.
I've not done it the most efficient way at all, but muddled through and it works well.
it would probably helpmore if i knew what x and y are for or even better, a list of mamehooker commands
-
You have set a 3 variables serial message coming from mamehooker: the first is the arduino pin you want to control, the second the state of the pin you want to set and the third is a terminal message (x) that tells arduino to do its magic. In this case is a simple digitalWrite that resembles the new state of the pin, but it could be any function.
-
You have set a 3 variables serial message coming from mamehooker: the first is the arduino pin you want to control, the second the state of the pin you want to set and the third is a terminal message (x) that tells arduino to do its magic. In this case is a simple digitalWrite that resembles the new state of the pin, but it could be any function.
im damn potato, cant do s h i t with this arduino LOL im a keep trying do...
-
Howard asked you on post #2 some detail. For sure giving him an answer could help you ;)
Don't expect people write code for you (it's difficult to debug an hardware without... the hardware!) but some help could come.
-
Howard asked you on post #2 some detail. For sure giving him an answer could help you ;)
Don't expect people write code for you (it's difficult to debug an hardware without... the hardware!) but some help could come.
well english is my second lenguage so i thought when he said i could figure it out my self from the drop down menu, to actually find the answer myself.
-
Im a drop the arduino and start a new topic with a pacdrive. thanks guys.
-
Because English is your second language, the private message you sent me left me scratching my head. I wasn't sure what you were wanting help with exactly. When the guys jumped in I assumed the info they gave you would be enough for you to figure it out. Sorry I wasn't more help.
-
Because English is your second language, the private message you sent me left me scratching my head. I wasn't sure what you were wanting help with exactly. When the guys jumped in I assumed the info they gave you would be enough for you to figure it out. Sorry I wasn't more help.
Basacly i dont mind buying you a beer or pay whatever amount you ask for the solution, please forgive me if im to hard to understand.let me know if you want me to explain everything again.
-
Well I can't write a script for you or program your Arduino because I don't have the hardware you do. I can answer specific questions though. Just going by what you told me it sounds like your issue is the hopper and you want mamehooker to send pulses to it. It makes far more sense to alter the Arduino code to accept a number for the hopper output and have it send the pulses. To do that you use a "For Loop" where you turn the pin off, use the "delay" command and then turn the pin back on, looping for whatever value is passed from mamehooker. I would link to some example code, but the descriptions are going to be in English, so it might be better for you to search for "Arduino For loop" in your own language.
-
well , im not sure if the "for loop" option for arduino suits my needs, so lets start little by little.
With the following code in the arduino and the mamehooker ini for the game, i can send the coins being paid out no problem, 5 coins 5 pulses, x mount of coins = same x amount of pulses. the problem is, the arduino starts with the pin on, when it should be off, if i use LOW instead of OUTPUT in the arduino code it starts with the pin off, but mamehooker wont send the pulses. Can we start by solving this please. heres the code. Im posting the code again, im using pin 55 as the output, adn a relay to catch the coin pulses, not sure if the video gets the clicks clear enough. Please pardon my ignorance and thanks for the patience. Ps im using an arduino mega and a 5v relay.
https://mega.nz/embed#!CZFSgSJa!B0ye7KlKuQfPEX7-YjYtFB5ZkX80RSFQwRJEjDJ2EOQ (https://mega.nz/embed#!CZFSgSJa!B0ye7KlKuQfPEX7-YjYtFB5ZkX80RSFQwRJEjDJ2EOQ) small video
void setup() {
Serial.begin(9600);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(55, OUTPUT);
}
void loop() {
while (Serial.available() > 0) {
int pin = Serial.parseInt();
int value = Serial.parseInt();
if (Serial.read() == 'x') {
digitalWrite(pin, value);
Serial.println();
}
}
}
[General]MameStart=cmo 4 baud=9600_parity=N_data=8_stop=1
MameStop=cmc 4
StateChange=
OnRotate=
OnPause=
[KeyStates]
RefreshTime=
[Output]
lamp1=cmw 4 2., cmw 4 %s%, cmw 4 x
lamp2=cmw 4 3., cmw 4 %s%, cmw 4 x
lamp3=cmw 4 4., cmw 4 %s%, cmw 4 x
lamp4=cmw 4 5., cmw 4 %s%, cmw 4 x
lamp5=cmw 4 6., cmw 4 %s%, cmw 4 x
lamp8=cmw 4 9., cmw 4 %s%, cmw 4 x
lamp6=cmw 4 7., cmw 4 %s%, cmw 4 x
lamp0=
lamp9=cmw 4 10., cmw 4 %s%, cmw 4 x
lamp12=cmw 4 13., cmw 4 %s%, cmw 4 x
lamp7=cmw 4 8., cmw 4 %s%, cmw 4 x
lamp10=cmw 4 11., cmw 4 %s%, cmw 4 x
lamp11=cmw 4 12., cmw 4 %s%, cmw 4 x
lamp13=cmw 4 13., cmw 4 %s%, cmw 4 x
led2=cmw 4 55., cmw 4 %s%, cmw 4 x
-
So you want the value sent by mamehooker to be inverted when it reaches the Arduino.... well just do that then.
Right now you have:
digitalWrite(pin, value);
Instead of writing "value" you need to write the inverse so make an "if then" statement to invert it. So replace that line with the following lines:
if (value = 0)
{
digitalWrite(pin, 1);
}
else
{
digitalWrite(pin,0);
}
The might not work btw because I'm essentially coding blind without the hardware, but I think that should allow you to start with LOW
-
It's likely using "!value" in place of "value" will work too
digitalWrite(pin, !value);
pinMode defines if the pin is an input or an output, so declaring LOW arduino trash the (non correct) information and define it as an input (default): that's why it stops working.
-
I always forget about "not" commands.... different syntax in my language of choice.
Anyway, you'd know more than me. I've done exactly two projects with Arduino. I just know that inverting it in mamehooker is way more involved so that isn't the way to do it.
-
Yesterday was late and I'm at work right now, can't wait to get back home and test both options, will post my results, thanks guys
-
It's likely using "!value" in place of "value" will work too
digitalWrite(pin, !value);
pinMode defines if the pin is an input or an output, so declaring LOW arduino trash the (non correct) information and define it as an input (default): that's why it stops working.
did not work, pin starts on HIGH still
if (value = 0)
{
digitalWrite(pin, 1);
}
else
{
digitalWrite(pin,0);
}
-
So you want the value sent by mamehooker to be inverted when it reaches the Arduino.... well just do that then.
Right now you have:
digitalWrite(pin, value);
Instead of writing "value" you need to write the inverse so make an "if then" statement to invert it. So replace that line with the following lines:
if (value = 0)
{
digitalWrite(pin, 1);
}
else
{
digitalWrite(pin,0);
}
The might not work btw because I'm essentially coding blind without the hardware, but I think that should allow you to start with LOW
this worked, pin started off but i fire up mamehooker and mame and the coins dont trigger the relay. it just stays off.
void setup() {
Serial.begin(9600);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(55, OUTPUT);
}
void loop() {
while (Serial.available() > 0) {
int pin = Serial.parseInt();
int value = Serial.parseInt();
if (value = 0)
{
digitalWrite(pin, 1);
}
else
{
digitalWrite(pin, 0);
}
}
}
-
Howard, do you think it will be easyer to achieve this with the pacdrive? as in MFME does? if so, then ill just doit with a pacdrive.
-
That should probably be "if (value == 0)".
-
You removed the end message to the code ("x"): why is that?
It's very unlikely that settin !value doesn't work...
Another way to write it could be
value=!value;
digitalWrite(pin, value);
But it's equivalent.
-
You removed the end message to the code ("x"): why is that?
It's very unlikely that settin !value doesn't work...
Another way to write it could be
value=!value;
digitalWrite(pin, value);
But it's equivalent.
Arduino:1.8.8 (Windows 10), Tarjeta:"Arduino Mega ADK"
C:\Users\Shaggy\Documents\Arduino\sketch_jan31a\sketch_jan31a.ino: In function 'void loop()':
sketch_jan31a:20:9: error: expected unqualified-id before '!' token
int !value = Serial.parseInt();
^
sketch_jan31a:22:24: error: 'value' was not declared in this scope
digitalWrite(pin, !value);
^
exit status 1
expected unqualified-id before '!' token
Este informe podría contener más información con
"Mostrar salida detallada durante la compilación"
opción habilitada en Archivo -> Preferencias.
-
int !value = Serial.parseInt();
Remove the exclamation from that.
-
int !value = Serial.parseInt();
Remove the exclamation from that.
as stated before, pin starts on high or on, wich if i where using a hopper it would be spiting all coins.
-
Why don't you immediately set it to low after initialization then?
It's starting to sound like you want to get this working for gambling purposes. I'm not sure if I feel comfortable with that.
-
He has not understeded the code, nor what mamehooker is outputting, in my opinion, and trying to have this thing working by "creative" code manipulation... It will never work.
-
Why don't you immediately set it to low after initialization then?
It's starting to sound like you want to get this working for gambling purposes. I'm not sure if I feel comfortable with that.
I would love to have a working casino machine with name games in my house, I already have a working casino cabinet with mfme so no, I don't want to profit this things , if I wanted to do that I could just buy the igrosoft boards and go with it, maybe it would be even cheaper as those boards are about 80 bucks. I will continue to search for a solution , thanks for any help.
-
He has not understeded the code, nor what mamehooker is outputting, in my opinion, and trying to have this thing working by "creative" code manipulation... It will never work.
I'm pretty sure there is a solution , and I will find it
-
There's a solution for sure man, but you should study the starting code trying to understand every single line. After that you can start toying with it and you will surely find the way.
Actually you have not mastered that code, it's so clear... Spend some time on that first ;)
-
Hi Guys,
https://www.youtube.com/watch?v=LWEIxmUra0Q
Eric
-
Please do not use mamehooker for gambling purposes. I'll be forced to remove my software from the usual sites and quit releasing public updates if I find gambling machines running my software out in the wild.
-
works
const int optoPin = 8; //this is the pin to which the optoswitch is connected
const int relePin = 3;
int pin;
int value;
bool optoState; //status of the opt
bool lastOptoState; //previous state of the opt
int coins = 0;
unsigned long startTime;
#define TIMEOUT 10000
//mamehooker setting cmw 4 %s%x on led2
void setup() {
pinMode(optoPin, INPUT_PULLUP);
pinMode(relePin, OUTPUT);
digitalWrite(relePin, LOW);
Serial.begin(9600); //start of serial communication
optoState = digitalRead(optoPin);
}
void loop() {
checkForCredits();
releaseTokens();
tokensCountDown();
}
void checkForCredits() {
while (Serial.available() > 0) {
value = Serial.parseInt();
if (Serial.read() == 'x') {
if (value > 0) {
coins ++;
}
}
}
}
void releaseTokens() {
if (coins > 0) {
// If the engine is stopped, I memorize the moment it starts.
// This way I make sure to set the variable only on the rising edge of relePin
if(digitalRead(relePin) == LOW){
startTime = millis();
}
digitalWrite(relePin, HIGH); //token release
optoState = digitalRead(optoPin);
}
else {
digitalWrite(relePin, LOW); //STOP token release
}
// Only if the engine is still running, after 10 seconds from activation, I reset the output
if(digitalRead(relePin) == HIGH){
if(millis() - startTime > TIMEOUT ){
digitalWrite(relePin, LOW); //STOP token release
Serial.println("refill");
Serial.print("gettoni non erogati:");
Serial.println(coins);
coins = 0;
delay(100);
}
}
}
void tokensCountDown() {
if (optoState != lastOptoState) { // if the status of the opt has changed (i.e. something is passing, in or out)
lastOptoState = optoState;
delay (100); //"economic" debounce (this is because in the change of state there may be fluctuations that lead to incorrect counts)
if (lastOptoState == LOW && coins > 0) {
coins = coins - 1 ; //decrease tokens
startTime = millis(); //reset timer
Serial.print("numero gettoni:");
Serial.println(coins);
}
}
}