Input and Output

Hi,
i want to use my us sensor with an panda fez 2.
But i don’t know how to convert a Output to an Input.
Us sensor : http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
My code :

public long US()
        {
            long duree, distance;
            OutputPort USport = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di52, false);
            Thread.Sleep(2);
            USport.Write(true);
            Thread.Sleep(5);
            USport.Write(false);
            USport = null;
            InputPort USport = new InputPort((Cpu.Pin)FEZ_Pin.Digital.Di52, false, Port.ResistorMode.Disabled); //don't work }

but the end of my code don’t work, help me please.

you should just look at the code on the codeshare.
http://www.tinyclr.com/codeshare/entry/123

1 Like

thanks, but i have a new question :slight_smile:

i can use tristateport with an digital pin ?

can i write ? :


            private TristatePort FEZ_Pin.Digital.Di52; 
            
            
            public Ping(Cpu.Pin pin) {


            TristatePort _pin = new TristatePort(pin, false, false, Port.ResistorMode.Disabled);

            }

or i have to write :

 private TristatePort Di52; 

?

You give pin number to the TristatePort constructor. TristatePort variable you can name any way you want.