Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Interruption or While loop

Interruption while loop work modes multithreading miltithread

  • Please log in to reply
No replies to this topic

#1 chuyi2ock

chuyi2ock

    New Member

  • Members
  • Pip
  • 1 posts

Posted 03 October 2014 - 02:06 AM

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.







Also tagged with one or more of these keywords: Interruption, while loop, work modes, multithreading, miltithread

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.