const int POTPIN = 2; //POTENTIOMETER circuit is on PA2 const int MOSFETPIN = 4; //Motor circuit is on PA04 const int HALLPIN = 5; //Hall Effet sensor circuit is on PA05 int val = 0; int sensor = 0; void setup() { Serial.begin(9600); pinMode(POTPIN, INPUT); //POTENTIOMETER circuit is on PA2 pinMode(MOSFETPIN, OUTPUT); //Motor circuit is on PA04 pinMode(HALLPIN, INPUT); //Hall Effet sensor circuit is on PA05 } void loop() { sensor = 800-analogRead(HALLPIN); //Read POTENTIOMETER input if (abs(sensor) > 200){ analogWrite(MOSFETPIN, 0); //Secures pump motor if upper tank is full delay(5000);} else{ val = analogRead(POTPIN); //Read POTENTIOMETER input delay(10); Serial.println(val); //Print POTENTIOMETER value analogWrite(MOSFETPIN, val);} }