Hello Netduino community, I'm new working with this platform and have some conflicts on the efficient use of multithreading that Netduino offers. I'm working on a system with 2 modes (LOCAL / REMOTE) each involves different actions. Can i use the selector as an interruption?
I'm using a while loop currently and i want to know if there are another ways to do it.
static InputPort button1 = new InputPort(Pins.GPIO_PIN_D2,false,Port.ResistorMode.Disabled); static InputPort button2 = new InputPort(Pins.GPIO_PIN_D3,false,Port.ResistorMode.Disabled); static InputPort Selector = new InputPort(Pins.GPIO_PIN_D4,false,Port.ResistorMode.Disabled); static OutputPort Led1 = new OutputPort(Pins.GPIO_PIN_D5, false); static OutputPort Led2 = new OutputPort(Pins.GPIO_PIN_D6, false); public static void Main() { while (true) { if (Selector.Read()) //MANUAL MODE { if (button1.Read()) { Debug.Print("LED1 ON"); Led1.Write(true); } else { Debug.Print("LED1 OFF"); Led1.Write(false); } } else //REMOTE MODE { if (button2.Read()) { Debug.Print("LED2 ON"); Led2.Write(true); } else { Debug.Print("LED2 OFF"); Led2.Write(false); } } } }
I accept suggestions.
Thanks.