Skip to content

ReadDigital returns 0 until input occurs, then input has input pullup behavior. #7

@GoogleCodeExporter

Description

@GoogleCodeExporter
Hopefully this is still being monitored.  I'm trying to use Sharpduino for 
examples in a high school programming class.

I'm continously polling ArduinoUno.ReadDigital to get input from my Arduino.  
The problem is that before I send input, ReadDigital returns 0, but after I 
send input, ReadDigital returns 1 for no input and 0 for input.  That means 
that I can't rely on the return value of ReadDigital until AFTER input occurs 
(because the initial 0 readings would be interpreted as input being present).

I tried just adding a check to Pin.CurrentMode

        public PinModes CurrentMode
        {
            get { return _currentMode; }
            set
            {
                _currentMode = value;
                if (_currentMode == PinModes.Input)
                {
                    // input uses pullup resisters so set CurrentValue to 1
                    CurrentValue = 1;
                }
            }
        }

But by the time I call ReadDigital, CurrentValue is somehow set back to 0.  I'm 
not sure how to either 1) ensure that the initial input is "1" for no  input or 
2) not read the input until input occurs.

Original issue reported on code.google.com by carolers...@gmail.com on 3 Nov 2013 at 7:40

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions