I have a very simple test sketch in which I\'m trying to set a pin to HIGH and then read its state with digitalRead. Here is my sketch.
<
Are you trying to set the default input to HIGH?
If so you are looking to activate the pull-up register:
void setup()
{
Serial.begin(9600);
}
void loop()
{
delay(1000);
pinMode(3,INPUT); // default mode is INPUT
digitalWrite(3, HIGH); // Turn on the internal pull-up resistor, default state is HIGH
delay(1000);
Serial.println(digitalRead(3));
}
Excerpt from DigitalWrite:
If the pin is configured as an INPUT, writing a HIGH value with digitalWrite() will enable an internal 20K pullup resistor.