Welcome Guest, you are in: Login

Netduino Wiki

RSS RSS

Navigation





Search the wiki
»

PoweredBy

GO! Module - Button

RSS
Modified on 2012/06/05 18:21 by Matt Isenhower Categorized as Netduino GO!, Netduino GO! Modules
The netduino GO! Button module is a single button. The button class has three features, the pressed and released events, and the ButtonState property.

Here is a quick video I (Omar) made to show what can be done with it and how:

Sample Code:
using System.Threading;
namespace NetduinoGo_Test
{
    public class Program
    {
        static NetduinoGo.RgbLed led = new NetduinoGo.RgbLed();
        static NetduinoGo.Button button = new NetduinoGo.Button();

        public static void Main()
        {
            led.SetColor(0, 0, 0);

            button.ButtonPressed += new NetduinoGo.Button.ButtonEventHandler(button_ButtonPressed);
            button.ButtonReleased += new NetduinoGo.Button.ButtonEventHandler(button_ButtonReleased);

            Thread.Sleep(Timeout.Infinite);
            
            // Or for the same behavior with no events, use the code below.

            //while (!button.ButtonState)
            //{
            //    // wait!
            //}

            //while (true)
            //{
            //    if (button.ButtonState)
            //        led.SetColor(0, 255, 0);
            //    else
            //        led.SetColor(255, 0, 0);
            //}
        }

        static void button_ButtonReleased(object sender, bool buttonState)
        {
            led.SetColor(0, 255, 0);
        }

        static void button_ButtonPressed(object sender, bool buttonState)
        {
            led.SetColor(255, 0, 0);
        }
    }
}
Where to buy:
  Name Size
- Button Module.zip 12.02 KB
- NetduinoGo.Button.NETDriver.zip 3.14 KB

ScrewTurn Wiki version 3.0.4.560. Some of the icons created by FamFamFam.