You can use the core Output port, in your example you could do the following.
// Get the output port for pin 37. Set the initial state to false.
Microsoft.SPOT.Hardware.OutputPort pin = new Microsoft.SPOT.Hardware.OutputPort((Microsoft.SPOT.Hardware.Cpu.Pin)37, false);
// Write the state to the pin
pin.Write(true);
Actually for a button you want to use an InputPort. If you use it on a port that supports interrupts you can use the .Interrupt event, otherwise you’ll need a thread constantly calling .Read to check the state.
If I define the “InutPort”, how can I define a Interrupt event for the IO37 pin?
void ProgramStarted()
{
......
...............
static InputPort GPIO_Pin_4 = new InputPort((Cpu.Pin)GHIElectronics.NETMF.FEZ.FEZ_Pin.Digital.IO37, true, Port.ResistorMode.PullDown);
// how can I define a interrupt event for the IO37 ???
}
Yes as Brett said sorry I wasn’t more clear. InputPort if it does NOT support interrupt on the pin and constantly call .Read; InterruptPort if it DOES.
You can see what pins do and dont support interrupt on the product page for your device. Interruptible pins are marked with a *.