Hi, I just would like to mention that there is another method of reading anolog Inputs if you are using 4.2 and ND2 (+?). You can just set some Properties of the class of type AnologInput and you´re (almost) done with math. (See the ReadScaled method in code) Here´s an example of both methods (ReadingRaw and ReadingScaled):
static AnalogInput voltagePort = new AnalogInput(AnalogChannels.ANALOG_PIN_A0); // Use for Netduino Plus 2//AnalogInput voltagePort = new AnalogInput(Pins.GPIO_PIN_A1); // For Standard Netduino public static void Main() { while (true) { Debug.Print(ReadScaled().ToString("f") + "," + ReadRaw().ToString("f")); Thread.Sleep(300); } } public static double ReadScaled() { const double maxVoltage = 3.3; voltagePort.Scale = maxVoltage; voltagePort.Offset = 0.0; double voltagevalue = voltagePort.Read(); //double realworldvalue = (((voltagevalue - 0.5) * 1000) / 10) - 4; return voltagevalue; } public static double ReadRaw() { const double maxVoltage = 3.3; const int maxAdcValue = 4095; //12bit AD converter in ND2+ double rawValue = voltagePort.ReadRaw(); double voltagevalue = (rawValue * maxVoltage) / maxAdcValue; //double realworldvalue = (((voltagevalue - 0.5) * 1000) / 10) - 4; return voltagevalue; }