Main Site Documentation

Flex sensor


#1

hello,
i connected a flex sensor : https://www.sparkfun.com/products/8606
to my fez panda 2.
but when i launch my debugging, after a moment i have an error with GHIElectronics.NETMF.Hardware.dll
and Debug.print, print nothing.
my code :


using System;
using System.Threading;
using System.Text;
using Microsoft.SPOT;
using System.IO;

using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.IO;

using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.IO;
using GHIElectronics.NETMF.System;



namespace FEZ_Panda_II_Application1
{
    public class Program
    {
        public static void dP() {
             AnalogIn Flex = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An0);
             long voltage = Flex.Read();
             String ecrir = voltage.ToString();
             Debug.Print(ecrir);
         }
               public static void Main()                                                              
        {
            while (true)
            {
                dP();
            }
        }

}}

help plz


#2

the error is linked to AnalogIn, but why ?


#3

try to move “AnalogIn Flex = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An0);” outside of the method dp()…


public class Program
{
        AnalogIn Flex = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An0);
        public static void dP()
        { 
            long voltage = Flex.Read();
            String ecrir = voltage.ToString();
            Debug.Print(ecrir);
         }
    
        public static void Main()                                                              
        {
            while (true)
            {
                dP();
            }
        }
 }


#4

i moved all from dp() method to Main(), and it works ! Thanks !


#5

YW :slight_smile: