Jump to content

writing NES controller-to-midi function for MBHP Core (pic)?


Recommended Posts

Posted

Hey guys,

It's been awhile since I have posted, but every year I seem to need this application, and always figure out some hacky way to get around it.

I am wanting to write an app that presses play on my sequencer when I push a button on an NES controller. I am basically going to tap the "Data" out on the NES controller, and wire that into the AIN pin on an MBHP Core module. I figured I would not need an AIN module, since I am just looking to start a song on *any* data piped into the AIN (so no multiplexing required). Would this work? Any ideas for how I should go about writing this application? I could not figure out what functions to call. I think the program needs to run like this:

Start:

Initialize; //vague, sorry, I'm not sure what to do here actually

Set MB module as "master" to all connected devices;

Mainloop:

Poll for any change in AIN;

On change, send start/stop signal to all connected devices;

goto mainloop

end

Posted

You could try following example: http://www.ucapps.de/mios_c_send_ain.html

with following code in AIN_NotifyChange()


unsigned int last_pin_value;
void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam
{
if( pin == 0 ) {
if( pin_value >= 700 && last_pin_value < 700 ) {
// Rising Edge at ca. 70% of 5V (-> 3.5V)
// Send MIDI Start Event
MIOS_MIDI_TxBufferPut(0xfa);
} else if( pin_value < 300 && last_pin_value >= 300 ) {
// Falling Edge at ca. 30% of 5V (-> 1.5V)
// Send MIDI Stop Event
MIOS_MIDI_TxBufferPut(0xfc);
}

last_pin_value = pin_value;
}
}
[/code]

Thats all.

There are also other methods to do this (e.g. using J5 pins as digital inputs), but you asked for the AIN solution, and I want to demonstrate how this can be done.

There is no real disadvantage by using an analog pin for this function - in distance, you get the advantage that you are able to define the hysteresis (as demonstrated above).

So, your idea doesn't match with the standard approach, but it isn't so bad! :)

More details about C programming can be found here:

http://www.ucapps.de/mios8_c.html

Best Regards, Thorsten.

Posted

Thanks for this code and info TK! I am going to try implementing this, and then see if I can gradually write something more advanced (like different buttons on the joypad controlling different midi events). And see how far I can get without an AIN/DIN module, and decide if I need one after all.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...