Raptor and Breadboard Module

Hello Everyone. I have just recently started learning C# and .NETMF to use as an industrial control project for work. We are going to have a series of digital inputs activate a sequence of controlled events based on analog inputs and HMI interface through the T43 display.

To start, I cannot figure out how to just print in the debug window the status of a button press using the breadboard module.

I know it is very basic…however, I cannot figure out how to monitor the status of a button press into the breadboard module. Current code is attached.

Any help is appreciated. Thank you, Jordan

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using Microsoft.SPOT.Hardware;

namespace GadgeteerApp6
{
public partial class Program
{
private object Status;

    // This method is run when the mainboard is powered up or reset.   
    void ProgramStarted()
    {
        Debug.Print("Program Started");

      breadBoardX1.CreateDigitalInput(GT.Socket.Pin.Four, GT.SocketInterfaces.GlitchFilterMode.On, GT.SocketInterfaces.ResistorMode.Disabled);
      breadBoardX1.CreateDigitalOutput(GT.Socket.Pin.Three, true);          

    }
  }
}

Hi there Jordan, and welcome to the forum.

There are a couple of ways to go about what you’re wanting to do - and I could throw you a fish but I prefer to teach you how to catch them yourself :slight_smile:

https://www.ghielectronics.com/docs is a good reference, and there’s a work-in-progress “Introduction to .Net Gadgeteer” that really will help you out. You’ll want to step through some of the basics if you haven’t already, and importantly you’ll see things like keeping objects to refer to later (as your code above doesn’t retain the outcome of the CreateDigitalInput and output calls you make)

A key concept you probably want for button presses are Interrupts rather than a pure digital input, that way the hardware is going to tell your code when it needs to respond, rather than you continually looking at the input pin and seeing if its state has changed. In your interrupt handler, you’re going to print out the status of the pin. The reference (non Gadgeteer, but can help you with the concept) is https://www.ghielectronics.com/docs/5/digital-inputs

You might also want to check out the exclamation mark in sockets in https://www.ghielectronics.com/docs/305/gadgeteer-sockets-quick-reference to make sure you know which pin to use (hint: interrupts are only guaranteed to be on pin3)