Buttons don't seem to respond consistently

I have a new FEZ Spider Starter Kit that I’m trying out, and have a question regarding button handling.

I’ll start by mentioning that the Spider is updated with recent firmware.

I’m trying to simply get the board to emit a message whenever the button is pressed, using this code. I can set a breakpoint in ProgramStarted and control flows through there. Only about 1 out of every 10 button presses causes the “Button Pressed” message to display.

void ProgramStarted()
	button.ButtonPressed += new Button.ButtonEventHandler(ButtonPressed);
	Debug.Print("Program Started");

void ButtonPressed(Button sender, Button.ButtonState state)
	Debug.Print("Button pressed");

I’ve checked the obvious things like making sure it’s connected to the correct port, and have swapped to a different button.

Generally things seem to be working – I wrote another program to cycle the LED through colors and that runs successfully:

while (true)



The only explanation I have is not having latest firmware. What is the button DLL version?

In addition to what Gus said…

There’s also always a possibility of a bad button. Do you have a meter and can test continuity across the button when it’s pressed?

Button checks out fine on the meter.

When I run the firmware updater, it is using:

C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\EMX\Firmware\CLR.HEX;C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\EMX\Firmware\CLR2.HEX;C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\EMX\Firmware\Config.HEX;

for the TinyBooter and firmware from:

C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\EMX\Firmware\TinyBooter\TinyBooter.GHI

After updating, the updater says that I have TinyBooter and Firmware

The project is referencing C:\Program Files (x86)\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\Button\NETMF 4.1\GTM.GHIElectronics.Button.dll which is marked with version 4.0.30319.

Here’s the complete set of references:

    <Reference Include="GHIElectronics.Gadgeteer.FEZSpider, Version=, Culture=neutral, processorArchitecture=MSIL" />
    <Reference Include="GTM.GHIElectronics.Button, Version=, Culture=neutral, processorArchitecture=MSIL" />
    <Reference Include="GTM.GHIElectronics.MulticolorLed, Version=, Culture=neutral, processorArchitecture=MSIL" />
    <Reference Include="Microsoft.SPOT.Graphics" />
    <Reference Include="Microsoft.SPOT.Hardware" />
    <Reference Include="Microsoft.SPOT.Hardware.SerialPort" />
    <Reference Include="Microsoft.SPOT.IO" />
    <Reference Include="Microsoft.SPOT.Native" />
    <Reference Include="Microsoft.SPOT.Net" />
    <Reference Include="Microsoft.SPOT.Net.Security" />
    <Reference Include="Microsoft.SPOT.TinyCore" />
    <Reference Include="mscorlib" />
    <Reference Include="System" />
    <Reference Include="System.Http" />
    <Reference Include="System.IO" />

Open the release notes file found in the GHI folder in “program files”. Compare it to what you see in release notes on this website.

If your firmware is version is, you do not have the latest firmware. Try checking the Downloads page for the newest SDK. The SDK and assemblies you have had a problem with the button driver. Once updating to the latest SDK, make sure you either start a new project, or remove and replace all of your assemblies.