Hello,
I am attempting to test the potentiometer, button, and RGBLed go modules. The following code worked until I upgraded to 4.2.2. Any suggestions are appreciated.
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoGo;
namespace PotGoSocketOnly
{
public class Program
{
static NetduinoGo.RgbLed led = new NetduinoGo.RgbLed(GoSockets.Socket4);
static NetduinoGo.Potentiometer pot = new NetduinoGo.Potentiometer(GoSockets.Socket3);
static NetduinoGo.Button button = new NetduinoGo.Button(GoSockets.Socket2); // this button will start/stop the flashing
public static bool currentState = false; // keep track of if the button was pressed to turn it on, or off
public static void Main()
{
// write your Main code here
button.ButtonReleased += new NetduinoGo.Button.ButtonEventHandler(button_ButtonReleased);
// button.ButtonReleased += new NetduinoGo.Button.ButtonEventHandler(button_ButtonReleased);
currentState = false; //make sure we start with it off
while (true) //we're using a device, it will never end
{
if (currentState) // see if we should be displaying the LEDs or not
{
led.SetColor((byte)255, (byte)0, (byte)0); // turn on the red LED
System.Threading.Thread.Sleep((int)(100 * pot.GetValue()));
// pause for a moment based on the potentiometer state
led.SetColor((byte)0, (byte)0, (byte)0);
}
}
}
//button handler
static void button_ButtonReleased(object sender, bool isPressed)
{
currentState = !currentState; //set the state to the opposite of whatever we were before
Debug.Print("Button Has Been Pushed");
}
}
}