Hi,
Sorry if this was posted in another thread, I just received my netduino plus 2 today. I'm still playing with the button and LED. I'm interrested with event programming, this code is working well:
Imports Microsoft.SPOTImports Microsoft.SPOT.HardwareImports SecretLabs.NETMF.HardwareImports SecretLabs.NETMF.Hardware.NetduinoModule Module1 Dim led As New OutputPort(Pins.ONBOARD_LED, False) Public WithEvents boardButton As New InterruptPort(Pins.ONBOARD_SW1, False, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth) Public Sub Main() Thread.Sleep(Timeout.Infinite) End Sub Private Sub boardButton_OnInterrupt(ByVal port As UInteger, ByVal state As UInteger, ByVal time As DateTime) Handles boardButton.OnInterrupt Select Case port Case CUInt(Pins.ONBOARD_SW1) led.Write(CBool(state)) End Select End SubEnd Module
Then I tried to use both the InterruptEdgeHigh and InterruptEdgeLow, but it always fails at the second attempt to declare an InterruptPort:
Imports Microsoft.SPOTImports Microsoft.SPOT.HardwareImports SecretLabs.NETMF.HardwareImports SecretLabs.NETMF.Hardware.NetduinoModule Module1 Dim led As New OutputPort(Pins.ONBOARD_LED, False) Public WithEvents boardButtonHigh As New InterruptPort(Pins.ONBOARD_SW1, False, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh) Public WithEvents boardButtonLow As New InterruptPort(Pins.ONBOARD_SW1, False, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow) Public Sub Main() Thread.Sleep(Timeout.Infinite) End Sub Private Sub boardButton_OnInterrupt(ByVal port As UInteger, ByVal state As UInteger, ByVal time As DateTime) Handles boardButtonHigh.OnInterrupt, boardButtonLow.OnInterrupt Select Case port Case CUInt(Pins.ONBOARD_SW1) led.Write(CBool(state)) End Select End SubEnd Module
What prevents me from declaring a second InterruptPort for the same pin? I hope the answer is very, very complicated.
Thank you