# Switch logic for digital well pump pressure switch.

I have 2 slide switches, 2 positions each. Switch 1 for on pressures, switch 2 for off pressures. I am naming the four positions on90, on100, off110, off120. I am trying to figure out how to code this. It may be worth noting I am a first time poster(of anything ever), I have tinkering experience and beginner level programming knowledge. I have spent days on this and fear I am chopping down trees in the wrong forest. Any direction would be great. I am using an Arduino Micro. There is a pressure sensor on A0. Here is what I have so far:

``````int on90 = 11;
int on100 = 10;
int off110 = 9;
int off120 = 8;
int mpxPin = A0;
int mpxVal = 0;
int pumpPin = 12;

void setup ()  {
pinMode (on90,INPUT);
pinMode (on100,INPUT);
pinMode (off110,INPUT);
pinMode (off120,INPUT);
pinMode (pumpPin,OUTPUT);  }

void loop()   {

if (digitalRead(on90) == HIGH) && mpxVal == < 91);
}
digitalWrite(pumpPin,HIGH); }
``````

I have 2 slide switches, 2 positions each. Switch 1 for on pressures, switch 2 for off pressures. I am naming the four positions on90, on100, off110, off120.

Do you have external pullup or pulldown resistors? You are not using the internal pullup resistors, so you need external resistors. How ARE your switches wired?

That code you posted won't even compile.

``````mpxVal == < 91)
``````

mpxVal <= 91

Try the Auto Format tool in the IDE. It will tell you at least one reason why the code will not compile. Once it compiles then you can move on to sorting out other problems.

Do i assume right that your switches are wired as shown here below?

This should get you started

``````//macro for detection af raising edge
#define RE(signal, state) (state=(state<<1)|(signal&1)&3)==1

const int on90 = 11;
int on90S;
const int on100 = 10;
int on100S;
const int off110 = 9;
int off110S;
const int off120 = 8;
int off120S;

int onValue;
int offValue;

void setup(){
Serial.begin(115200);
}//setup()

void loop(){
onValue = 90;
Serial.println("onValue = 90");
}
onValue = 100;
Serial.println("onValue = 100");
}