Update. This circuit worked exactly like designed, BUT the AHK script it triggers could never issue an ESCAPE command to exit Mame.
I almost gave up several times.
I had an extra RPi Pico and I have a great idea.
Why not have the smart switch instead of triggering P1 left + P1 right to activate the AHK script, why not just have it trigger the Pico to issue the key press commands?
So I did that, it took the AHK script completely out of the picture.
So I programmed the Pico to send an ESCAPE key pressed to the pc, then a few seconds later send a V key pressed. (Im using V to exit mala) Then issue a shutdown command.
That didnt work either.
Mame just refused to exit and the PC would shutdown before Mala came back on screen.
Why am I so intent on doing this, you might ask? Well, I wanted to preserve the old cabinet feel of a toggle switch that you flip up to start the PC, then flip down to shut everything down.
Why worry about shutting down correctly, you might also ask?
Well Windows doesnt like to be shutdown improperly. And if you shutdown before Mala properly exits, the last emulator and game played will not pop up on the next Mala start up.
Looks like Mala saves all that info on a proper exit.
Again, I was about ready to shelve the whole idea. But my OCD would not allow that.
So I came up with another idea, program the Pico to do what my first circuit did, except send signals directly to the push buttons. first ESC then V.
This works like a charm!
Enough of these rambling on.
Here is a diagram of how I interfaced everything to the Pico.
I used opto-isolators to make sure nothing harms the PC of the key board emulator (Keywiz Max.)
I suppose you could use transistors, but I just feel safer with opto-isolators.
I used what i had in my junk box. I like the TIl119, but I thin kit is obsolete now, im sure just about any opto will work, but you may hae to adjust the input resistor values, and dont use the ones that have a base connection on pin6.
I tied the optos to the pins on the motherboard. (Power button and front panel ON Led).
I used a 150 ohm resistor on the PC is ON opto, that output on my PC is current regulated, so a resistor may not be necessary.
Some PC's go into sleep mode and the ON LED blinks, this cannot be used on this circuit. The signal must remain on solid when PC is on.
It can be tied to the 5 VDC power of the PC power supply if desired, but the resistor will need to be 300 or so ohms. I figured I could add a 150 ohm resistor to get 300, if I need to do that, but so far the ON led pins are working great for me.
Anyway, enough of this book.
Here is the schematic of how I wired everything to the Pico.
The Pico is powered by a 5 vdc regulated wall wart, (made for the RPi), that stays on all the time. (Cabinet off, Pico still on.)
I will post the code I wrote for the Pico soon, and maybe some pics of the setup.
Thanks for your attention to this matter.
