Pins are returning LOW instead of HIGH

I have a 3 position switch connected to pins 10,11,12. The following code works, but only because I negated the digitalRead value, e.g. if(!digitalRead(LOWPOS)).

I tried changing the digitalWrite to LOW in setup and used if(digitalRead(LOWPOS)), but that didn't work. I obviously have something backwards but can't figure out what.

I'm using a 3.3V Mini Pro

const byte LOWPOS = 10;
const byte MEDPOS = 11;
const byte HIGHPOS = 12;

void setup()
{
    pinMode(LOWPOS, INPUT);
    pinMode(MEDPOS, INPUT);
    pinMode(HIGHPOS, INPUT);

    digitalWrite(LOWPOS, HIGH);
    digitalWrite(MEDPOS, HIGH);
    digitalWrite(HIGHPOS, HIGH);
}

void loop()
{

    int Multiplier = 0;

    if(!digitalRead(LOWPOS))
        Multiplier = LOWMULT;

    if(!digitalRead(MEDPOS))
        Multiplier = MEDMULT;

    if(!digitalRead(HIGHPOS))
        Multiplier = HIGHMULT;

}

So you are turning the pull-ups on with the digitalWrite. You can use INPUT_PULLUP also.

What are you going to do with "Multiplier" in loop() ? And you can only have Multiplier = 10 or 11 or 12 Why?

Edit How is the switch wired?

What is the point of this ?

If the switch is wired in such a way that closing a contact connects a pin to ground, the input of the selected position will be LOW and the inputs of the inactive positions will be HIGH.

If that is the case (a schematic can clarify this), an easy trick is to define some constants.

// sensible names for active and inactive state of a switch connected to a pin
#define ACTIVE LOW
#define INACTIVE HIGH

void setup()
{
  ...
  ...
}

void loop()
{
  if (digitalRead(LOWPOS) == ACTIVE)
  {
    ...
    ...
  }
}

LarryD: So you are turning the pull-ups on with the digitalWrite. You can use INPUT_PULLUP also.

What are you going to do with "Multiplier" in loop() ? And you can only have Multiplier = 10 or 11 or 12 Why?

Edit How is the switch wired?

What is the point of this ?

Think of a fan, that has low, medium and high settings.

I'm using a 4PDT slide switch. One half of the switch controls power is connected in such a way that position 1 is ON, 2, 3, and 4 is ON. This literally controls power to the arduino.

The other side has the common pole going to ground, and positions 2, 3, and 4 going to the arduino pins 10, 11, and 12 respectively.

Switch is in position 1, then unit is off. Switch is in position 2, then unit is on, and the project will use a LOW setting Switch is in position 3, then unit is on, and the project will use a MEDIUM setting Switch is in position 4, then unit is on, and the project will use a HIGH setting

I'm using a 4PDT slide switch.

A 4PDT switch only has 2 positions.

Do you mean you have a 4 position slide switch?

Drawing and showing us a schematic of the circuit wiring would go a long way. Do you have a link to the switch?

This didn't help?

Usually, you would wire that common pin 3 to ground, then you would take each of the others to a pin set up as "INPUT_PULLUP". A high on the pin means the pin is off (not connected to ground), a low means it is on (connected to ground).

So yes, because LOW is zero and HIGH is nonzero, the sense of the if statements is reversed from what you would expect when checking switches.

External 10K pull-up resistors will provide a stronger signal, but the main problem in your code is that you're not accounting for the MAKE-BEFORE-BREAK conditions that occur on the terminals.

You have crucial information in the other thread referred to in reply #7. But you never mentioned it here. It would have been a whole lot less confusing and time wasting if you had just continued the other thread instead of starting this one.