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

Newbie: onboard button in a program


Best Answer Chris Walker, 14 May 2015 - 08:12 AM

Hi volleynerd,

This issue has been fixed in the new 4.3.2.2 firmware:
http://forums.netdui...-v432-update-2/

Thanks again for reporting the bug,

Chris Go to the full post


  • Please log in to reply
3 replies to this topic

#1 volleynerd

volleynerd

    Member

  • Members
  • PipPip
  • 11 posts

Posted 14 May 2015 - 12:22 AM

Hello - I'm back on the netduino bandwagon after playing with it a couple years ago.

 

I have a Netduino 3 WiFi board.  Trying to work with the onboard button in a program.  Should be so simple.  I've searched through the boards and web a bit, can't find an answer.

 

My understanding is that the onboard button is dual purpose - it will (a) reset the board, or ( B) if in a program with an InputPort bound to the ONBOARD_BTN, it should read button presses instead.

 

When running the program below, when I press the onboard button, the board resets.  

What am I doing wrong?

 

static OutputPort led = new OutputPort( Pins.ONBOARD_LED, false );
static InputPort button = new InputPort( Pins.ONBOARD_BTN, false, Port.ResistorMode.Disabled );
static bool buttonState = false;
 
public static void Main()
{
    led.Write( false );
    while ( true )
    {
        buttonState = button.Read();
        led.Write( buttonState );
    }
}
 

 



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 14 May 2015 - 01:06 AM

Hi volleynerd,

Ack, that's a bug. We physically wired up the button to two MCU pins on Netduino 3 Wi-Fi, but ONBOARD_BTN is pointing to the inactive pin. [The dual-wiring is there for some advanced future scenarios.]

In the meantime, can you please reply your line of code with the physical pin #--and let us know if that fixes the issue for you?
 
        //static InputPort button = new InputPort(Pins.ONBOARD_BTN, false, Port.ResistorMode.Disabled);
        /* replaced by... */
        static InputPort button = new InputPort((Cpu.Pin)0x15, false, Port.ResistorMode.Disabled);
We'll fix the core mis-assignment in a 4.3.2.2 quick patch by the weekend. Sorry for the glitch, and thank you very much for letting us know.

Chris

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 14 May 2015 - 08:12 AM   Best Answer

Hi volleynerd,

This issue has been fixed in the new 4.3.2.2 firmware:
http://forums.netdui...-v432-update-2/

Thanks again for reporting the bug,

Chris

#4 volleynerd

volleynerd

    Member

  • Members
  • PipPip
  • 11 posts

Posted 14 May 2015 - 03:36 PM

Yep, indeed with that workaround, the program works fine.  Little did I know I was "doing it right" ...  :)

 

Thanks a lot for the help!






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.