Hello Gadgeteer Button Module
Yesterday I wrote about the series of github repositories with Gadgeteer “Hello World” application coming.
Today, the button module repo is done (for now anyway…).
The Code
public partial class Program
{
void ProgramStarted()
{
Debug.Print("Program Started");
button.ButtonPressed += button_ButtonPressed;
button.ButtonReleased += button_ButtonReleased;
}
void button_ButtonReleased(Button sender, Button.ButtonState state)
{
button.TurnLEDOff();
}
void button_ButtonPressed(Button sender, Button.ButtonState state)
{
button.TurnLEDOn();
}
}
The code is fairly straight forward:
- React when the button is pressed or released.
ProgramStarted()
- Turn off the LED if the button is released.
button_ButtonReleased(...
- Turn on the LED if the button is pressed.
button_ButtonPressed(...