DigitalOutput.Read() problem?

This seems too simplistic to have gone unnoticed before now… Am I missing something? It appears that Read() always returns false. I’m using the latest 4.2 firmware. I know I can and should be keeping this state in a variable but I stumbled across this and left it as an example.

    public partial class Program
        private DigitalOutput p;

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
            var relayState = true;
            p = extender.SetupDigitalOutput(Socket.Pin.Three, false);
            button.ButtonPressed += (sender, state) =>
                                            relayState = p.Read();
                                            Debug.Print(relayState.ToString());     // Always prints "false".

Can you try a non gadgeteer project?

powerPin = new GTI.DigitalOutput(socket, GT.Socket.Pin.Three, false, null);
Debug.Print(powerPin.Read().ToString()); // Prints true…

Works for me…

Sorry, I didn’t get much time to get back to this.

Yea, but I’ll have to dig up the formula for mapping a Cerberus pin. If you don’t find something out sooner, I’ll look into it tomorrow night.

@ twospoons - Are you using a Hydra? My Hydra wasn’t readily available to test with. Perhaps the problem is isolated to the Cerberus. Also, maybe try my exact code snippet and see if you get the same results. They should be the same but you never know.

Hmm… I have the same issue with my cerb when I try to use pins directly. PD1 enum is mapped to pin 49. Apparently that’s not right.

So, on the cerb bee, what’s the correct pin enums to use for the arduino headers? I looked at the schematics and tried using the same numbers as shown there, but that didn’t work either.

Never mind, found it here;

FYI - I tried my original code again tonight and it still doesn’t work with the latest SDK.

@ ianlee74 - I took your exact code an tried it on the Spider, Hydra and Cerberus and all three worked. I have the button plugged into Socket 4 on the Cerberus.