RaspberryPi.Net icon indicating copy to clipboard operation
RaspberryPi.Net copied to clipboard

PinState always Low.

Open ghost opened this issue 11 years ago • 6 comments

Hi guys...

I ran into a problem... I received my Pi 2 days ago and since that im trying to get my code working on that machine. The problem is even when I press one of the 4 buttons I need to have - the PinState still stays at low.

I already checked it with Python and its fully working there.

Codesnippet:

    public static GPIOMem btn1 = new GPIOMem(GPIOPins.V2_Pin_P1_03, GPIODirection.In);
    public static GPIOMem btn2 = new GPIOMem(GPIOPins.V2_Pin_P1_05, GPIODirection.In);
    public static GPIOMem btn3 = new GPIOMem(GPIOPins.V2_Pin_P1_07, GPIODirection.In);
    public static GPIOMem btn4 = new GPIOMem(GPIOPins.V2_Pin_P1_08, GPIODirection.In);

    Console.WriteLine("State: " + btn1.Read() + " " + btn2.Read() + " " + btn3.Read() + " " + btn4.Read());

And the Output is:

State: Low Low Low Low

Hope you got an Idea to help me with that little problem...

ghost avatar Jan 21 '15 02:01 ghost

Which is the Raspberry Pi's version?

brunoamancio avatar Jan 30 '15 10:01 brunoamancio

Hi I have the same problem. The only way I can change input is by doing this: GPIOMem Input = new GPIOMem(GPIOPins.V2_GPIO_22, GPIODirection.In, true) //Input always high GPIOMem Input = new GPIOMem(GPIOPins.V2_GPIO_22, GPIODirection.In, false) //Input always low Button has no effect. I have tried with software pullup and pulldown resistors. I have a RPi model B+ My Python code also works fine with input

I hope someone can help - thanks in advance

DeeJay1984 avatar Feb 14 '15 21:02 DeeJay1984

I found the same problem. Its caused by the constuctor. The direction is set to out when writing the default value... You need to set direction after construction. (Or fix constructor of GPIO.cs)

Framil avatar Feb 15 '15 19:02 Framil

@Framil , that's true. Thank you for noticing that. At the moment I cannot fix the problem due to lack of time (exams of master's course). I could fix that after this month, though.

Anyone who has a little time could make the changes and make the pull request.

brunoamancio avatar Feb 15 '15 20:02 brunoamancio

Hey Framil Thanks.. It worked when I set the direction after construction. I am new in C# programming. Can you guide me to fix the error in the constructor. I have been trying to find/fix it for 3 hours without luck. There is a lot of the code I dont understand

DeeJay1984 avatar Feb 18 '15 20:02 DeeJay1984

I'm using Model B and ran into the same problem. I tried to use following method as mentioned by others (set the direction after construction) to solve this, but it doesn't work:

GPIOMem enable = new GPIOMem(GPIOPins.V2_GPIO_10);
GPIOMem step = new GPIOMem(GPIOPins.V2_GPIO_09);
GPIOMem dir = new GPIOMem(GPIOPins.V2_GPIO_11);

enable.PinDirection=GPIODirection.In;
step.PinDirection=GPIODirection.In;
dir.PinDirection=GPIODirection.In;

Any ideas?

yuzouDE avatar Jan 27 '20 08:01 yuzouDE