Error when setting up an AnalogInput

Trying to setup a typical AnalonInput and am getting an error in compiling. I pulled this code off of a few other posts here - with others using it just fine. For mine it’s saying that it’s not the right constructors? Should be something simple I’m missing. ?

namespace FrontDoorModule
{
public partial class Program
{

    private GT.Timer _pollingTimer;
    private AnalogInput analogInput;

    // This method is run when the mainboard is powered up or reset.   
    void ProgramStarted()
    {
        Debug.Print("Program Started");

        Socket socket = Gadgeteer.Socket.GetSocket(3, true, null, null);
        analogInput = new AnalogInput(socket, Socket.Pin.Three, null); //here's the problem line
        


        // Microsoft.SPOT.Hardware.AnalogInput does not contain a constructor



    }
}

}

Verbose - have you used the code insight feature of VS to see what the various constructors are? (I don’t have the SDK handy to see them).

If you type something like:

var a = Microsoft.SPOT.Hardware.AnalogInput(

Once you enter the ( it should show a little window with the constructor. If there are multiples, then there will be arrows and x of n to the left of the class name.

The error message you took a snapshot of says that the arguments you supplied do not match one of the constructors:

analogInput = new AnalogInput(socket, Socket.Pin.Three, null); //here's the problem line

There’s an issue with the type of variables being used and/or the quantity of variables being passed in.

The first image is (poor) snap shot of the default MailMessage constructor. Notice it has 4 total constructors available to use.

The second is the 2nd option.

you need to change the reference to AnalogInput.
it is not using the Gadgeteer one just the NETMF one.
Replace both AnalogInput in the declare statement with
Gadgeteer.Interfaces.AnalogInput;

1 Like

Thanks to both mhectorgato and Mike; you supplied me the ‘why’ and ‘how’.

Up and running now, thanks!

1 Like