Using the switch - Netduino Plus 2 (and Netduino Plus 1) - Netduino Forums
   
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

Using the switch


  • Please log in to reply
5 replies to this topic

#1 KÃ¥re

KÃ¥re

    New Member

  • Members
  • Pip
  • 6 posts

Posted 26 October 2011 - 08:11 PM

I am starting to play with the Netduino Plus, and until now, it seems to work really smooth :o) But I want to use the button on the board. The button is default a Reset button. To make it work as a switch button, to be read by the program, the /SW1_CTRL_OF_RESET output must be set to HIGH. This should be easy, but the output is not defined pr. default. The Pins is defines as: public static class Pins { public const Cpu.Pin GPIO_NONE = -1; public const Cpu.Pin GPIO_PIN_A0 = 59; public const Cpu.Pin GPIO_PIN_A1 = 60; public const Cpu.Pin GPIO_PIN_A2 = 61; public const Cpu.Pin GPIO_PIN_A3 = 62; public const Cpu.Pin GPIO_PIN_A4 = 10; public const Cpu.Pin GPIO_PIN_A5 = 11; public const Cpu.Pin GPIO_PIN_D0 = 27; public const Cpu.Pin GPIO_PIN_D1 = 28; public const Cpu.Pin GPIO_PIN_D10 = 54; public const Cpu.Pin GPIO_PIN_D11 = 17; public const Cpu.Pin GPIO_PIN_D12 = 16; public const Cpu.Pin GPIO_PIN_D13 = 18; public const Cpu.Pin GPIO_PIN_D2 = 0; public const Cpu.Pin GPIO_PIN_D3 = 1; public const Cpu.Pin GPIO_PIN_D4 = 12; public const Cpu.Pin GPIO_PIN_D5 = 51; public const Cpu.Pin GPIO_PIN_D6 = 52; public const Cpu.Pin GPIO_PIN_D7 = 3; public const Cpu.Pin GPIO_PIN_D8 = 4; public const Cpu.Pin GPIO_PIN_D9 = 53; public const Cpu.Pin ONBOARD_LED = 55; public const Cpu.Pin ONBOARD_SW1 = 29; } I could just add the SW1_CTRL_OF_RESET which is on port PA30. But the question is: How do I do that ??? I cannot figure out how these defines are used. Why is ONBOARD_LED defined as 55 ? It is on port PB23. I also tried to look at GPIO_PIN_D2 which is defined as 0. But port D2 is not even on the device ??? It only has PA and PB. I am really confused... Please help! BR KÃ¥re

#2 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 26 October 2011 - 08:30 PM

The reset is automatically disabled when you use Pins.ONBOARD_SW1 as an InputPort or InterruptPort, nothing you have to do in addition to that - the netduino is nice like that ;)
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#3 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 26 October 2011 - 09:48 PM

Why is ONBOARD_LED defined as 55 ? It is on port PB23.
I also tried to look at GPIO_PIN_D2 which is defined as 0.
But port D2 is not even on the device ??? It only has PA and PB.

"Dx" stands for "digital" and "Ax" for "analog", this is naming convention of Netduino header pins (compatible with Arduino). The microcontroller has two ports named PA and PB, individual bits are numbered in .NET Micro Framework PA0 = 0, PA1 = 1,... PA31 = 31, PB0 = 32, PB1 = 33 etc. Thus, the onboard LED on PB23 = 23 + 32 = 55 and pin "D2" on PA0 = 0.

The other numbers in the schematic (i.e. 81 for PA0, 82 for PA1, ..., 69 for PB23 etc.) denote package leads (resp. balls pads in case of Netduino Mini's TFBGA package).

#4 danilow

danilow

    New Member

  • Members
  • Pip
  • 1 posts

Posted 30 November 2011 - 01:42 AM

Hi, i'm new in the community :) and i have purchase my first netduino. I having the follow problem, may be you can help me a bit.... i have subscribed an event for an interruptport, event fires fine, but i cant identify what port is firing the event cause data 1 give me numbers that not match with de Pins enumerator. my event fires the follow code static void input_OnInterrupt(uint data1, uint data2, DateTime time) { lock (LockerConcurrency) { Debug.Print("Press Data1 = " + data1 + " Data2 = " + data2 + " @ " + time.ToString()); } } the question is how can i cast data1 to something more nmonic or to the pin enumerator has string to view in in the debug what port is pressed, i have all the digital input subscribed to the same method posted here. regards.

#5 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 01 December 2011 - 03:17 PM

i have subscribed an event for an interruptport, event fires fine, but i cant identify what port is firing the event cause data 1 give me numbers that not match with de Pins enumerator.

The port number parameter data1 should match Netduino Pins enumeration:

      ...
      switch((Cpu.Pin)data1)
      {
        case Pins.GPIO_PIN_D0:
          ...
          break;

        case Pins.GPIO_PIN_D1:
          ...
          break;
      }
Welcome to the community!

#6 Giuliano

Giuliano

    Advanced Member

  • Members
  • PipPipPip
  • 361 posts
  • LocationSimi Valley, CA

Posted 18 September 2012 - 01:53 AM

How to set ONBOARD_SW1 to its original state which is as reset button after using it in the code for a particular feature?




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.