Welcome Guest, you are in: Login

Netduino Wiki

RSS RSS

Navigation





Search the wiki
»

PoweredBy

GO! Module - Potentiometer

RSS
Modified on 2012/06/04 01:06 by Nevyn Categorized as Netduino GO!, Netduino GO! Modules
The netduino GO! potentiometer module has a single potentiometer.

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



Sample Code:

using Microsoft.SPOT;
namespace Module_Tests
{
    public class Program
    {
        public static void Main()
        {
            NetduinoGo.RgbLed led = new NetduinoGo.RgbLed();
            NetduinoGo.Potentiometer pot = new NetduinoGo.Potentiometer();

            // pot.GetValue() - Returns a float from 0 to 1. 

            while (true)
            {
                led.SetColor(0, 0, (byte)(pot.GetValue() * 255));
            }
        }
    }
}
Code with method to set a custom range:
using Microsoft.SPOT;
namespace Module_Tests
{
    public class Program
    {
        public static void Main()
        {
            NetduinoGo.RgbLed led = new NetduinoGo.RgbLed();
            NetduinoGo.Potentiometer pot = new NetduinoGo.Potentiometer();

            while (true)
            {
                led.SetColor(0, 0, (byte)(Map(pot.GetValue(), 0, 1, 0, 255)));
            }
        }

        // Used for mapping range of values to another range, linearly.
        public static float Map(float input, float inMin, float inMax, float outMin, float outMax)
        {
            return ((input - inMin) * (outMax - outMin) / (inMax - inMin) + outMin);
        }
    }
}
Where to buy:

Design and NETMF Source Files are attached!

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