[#XDUINO] Arduino vs Netduino vs Gadgeteer (III) example with Netduino

image

Series

  1. Introduction. https://elbruno.com/2013/07/13/xduino-arduino-vs-netduino-vs-gadgeteer-i/
  2. Example with Arduino. https://elbruno.com/2013/07/15/xduino-arduino-vs-netduino-vs-netgadgeeter-ii-usamos-el-arduino/
  3. Starting with Netduino. https://elbruno.com/2013/07/16/xduino-arduino-vs-netduino-vs-netgadgeeter-iii-empezamos-con-netduino/

Good.

After the introduction of the Netduinodevelopment yesterday, today we will see the implementation of the application using the Netduino. In the case of the Netduino 2 we can deploy the application using the board without connecting external sensors, since it has a BUTTON and an LED.

Creating a new project of type Netduino 2 Application and changing the target to NETMF 4.2 in the protective properties

image

The code would be as follows:

   1: using System.Threading;

   2: using Microsoft.SPOT.Hardware;

   3: using SecretLabs.NETMF.Hardware.Netduino;

   4:  

   5: namespace NetduinoApplication3

   6: {

   7:     public class Program

   8:     {

   9:         private static InterruptPort _boardButton;

  10:         private static OutputPort _boardLed;

  11:         private static bool _ledOn;

  12:  

  13:         public static void Main()

  14:         {

  15:             _boardLed = new OutputPort(Pins.ONBOARD_LED, false);

  16:             _boardButton = new InterruptPort(Pins.ONBOARD_BTN, 

  17:                 false, Port.ResistorMode.Disabled, 

  18:                 Port.InterruptMode.InterruptEdgeLow);

  19:             _boardButton.OnInterrupt += boardButton_OnInterrupt;

  20:             while (true)

  21:                 Thread.Sleep(Timeout.Infinite);

  22:         }

  23:  

  24:         static void boardButton_OnInterrupt(uint data1, uint data2, System.DateTime time)

  25:         {

  26:             _boardLed.Write(_ledOn);

  27:             _ledOn = !_ledOn;

  28:         }

  29:     }

  30: }

And the application works:

However what is interesting about this post is to show how we can do the same using the same Pan Groove that we use in the Netduino. In the following example, we will use this hardware:

As in the example of the Arduino from a few days ago will respect the Pins where I connect sensors, PIN 6 for LED and PIN 9 for the BUTTON (lines 15 and 16). Also in this example change the way in which change the State of the LED, the code is as follows:

   1: using System.Threading;

   2: using Microsoft.SPOT;

   3: using Microsoft.SPOT.Hardware;

   4: using SecretLabs.NETMF.Hardware.Netduino;

   5:  

   6: namespace NetduinoApplication3

   7: {

   8:     public class Program

   9:     {

  10:         private static InterruptPort _boardButton;

  11:         private static OutputPort _boardLed;

  12:  

  13:         public static void Main()

  14:         {

  15:             _boardLed = new OutputPort(Pins.GPIO_PIN_D6, false);

  16:             _boardButton = new InterruptPort(Pins.GPIO_PIN_D9, 

  17:                 false, Port.ResistorMode.Disabled, 

  18:                 Port.InterruptMode.InterruptEdgeLow);

  19:             _boardButton.OnInterrupt += boardButton_OnInterrupt;

  20:             while (true)

  21:                 Thread.Sleep(Timeout.Infinite);

  22:         }

  23:  

  24:         static void boardButton_OnInterrupt(uint data1, uint data2, System.DateTime time)

  25:         {

  26:             _boardLed.Write(!_boardLed.Read());

  27:         }

  28:     }

  29: }

And taking advantage of the Groove application assembles in seconds and works:

Saludos @ La Finca

El Bruno

image image image Google

One thought on “[#XDUINO] Arduino vs Netduino vs Gadgeteer (III) example with Netduino

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.