Im writing a Netduino 3 program that will control turn lights and other relays for hayrides. My program was written before I got the device, so Im not sure how well it will work, but Im already having a problem with one of the buttons (hazardButton
). When applying 3.3v
it doesn't cause the interrupt to trigger. Applying 5v
does the same, however when applying GND
it triggers the interrupt, but when re-applying GND
it doesn't turn off the interrupt.
Here's my code:
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace Tractor_Mate
{
public class Program
{
static InterruptPort hazardButton = new InterruptPort(Pins.GPIO_PIN_D0, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
static OutputPort hazardLights = new OutputPort(Pins.ONBOARD_LED, false);
static bool hazardsActive = false;
public static void Main()
{
Debug.Print("Initializing Inputs... ");
hazardButton.OnInterrupt += new NativeEventHandler(hazardButton_OnInterrupt);
Thread.Sleep(Timeout.Infinite);
}
static void hazardButton_OnInterrupt(uint data1, uint data2, DateTime time)
{
while (data2 == 0)
{
hazardLights.Write(true);
Thread.Sleep(500);
hazardLights.Write(false);
Thread.Sleep(500);
hazardsActive = true;
}
hazardsActive = false;
}
}
}
Im getting the problem with the Hazard Lights
and haven't tried any of the others yet. Im wiring the buttons up so that when the pin goes HIGH
it will trigger, and then when LOW
it turns it off.