Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Request For Help In Testing Pot, Button and RGBLed Go Modules

C#

Best Answer Chris Walker, 19 January 2013 - 03:01 PM

Hi Denisetoo, Your code should still work. Did you double-check that those modules are plugged into the specified GoPorts (sockets)? What exactly is happening now? What is not working? Also, do any of the GoPort LEDs light up when you start your app? Chris Go to the full post


  • Please log in to reply
2 replies to this topic

#1 Denisetoo

Denisetoo

    Member

  • Members
  • PipPip
  • 22 posts

Posted 19 January 2013 - 02:48 PM

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");
        }
 
 
 
       
    }
}
 


#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 19 January 2013 - 03:01 PM   Best Answer

Hi Denisetoo, Your code should still work. Did you double-check that those modules are plugged into the specified GoPorts (sockets)? What exactly is happening now? What is not working? Also, do any of the GoPort LEDs light up when you start your app? Chris

#3 Denisetoo

Denisetoo

    Member

  • Members
  • PipPip
  • 22 posts

Posted 19 January 2013 - 05:17 PM

Chris,

 

It worked the second time I ran it.  Thank you for your speedy response.







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.