hey all. yesterday i discovered a problem that doesn't make any since to me. If i attempt to serial print one of the values from my code the variable of the print part shows 16 squares. I listed it as an Int as the values are limited to 3 digits.
Here's the kicker of the situation. If i apply a 2 more serial prints on other values in my code just a few lines down, then all of the serial prints are correct as it should be, but it's not working on that one value by itself. but when it messes up, the code itself works normally, but won't print values, and i've never seen it do this before.
Here is the section of code where the prints are located.
int pumpReading = analogRead(pumpPin);
long pumpPeriod = map(pumpReading, 1023, 0, minPump, maxPump);
newPumpPeriod = pumpPeriod;
if ( abs (newPumpPeriod - oldPumpPeriod) > 2) {monitorPressure();}
int currentPressure = (analogRead(pressurePin)-SensorOffset); // Pressure check
randomPump = random(200, pumpPeriod); // Random pump time on generation
if (currentPressure > randomPump){
randomPump = random(currentPressure, pumpPeriod);
}
Serial.print("randomPump "); // won't print values by itself
Serial.println(randomPump);
digitalWrite(pumpRelay, LOW);
pumpMillisTime = millis();
pressureReading = (analogRead(pressurePin)-SensorOffset);
while (analogRead(pressurePin)-SensorOffset < randomPump) { // RANDOM PUMP
fillMillisTime = millis();
inflateTime = fillMillisTime - pumpMillisTime;
if (inflateTime > noPressureTime){
oldPressureReading = (analogRead(pressurePin)-SensorOffset);
if (oldPressureReading < pressureReading) { noPressure(); }
}
if (inflateTime >= pumpErrorTime){
digitalWrite(pumpRelay, HIGH);
digitalWrite(valveRelay, LOW);
for (int c = 0; c <= 2; c++){
display.printFixedN (0, 48, "Pumps Go", STYLE_NORMAL, FONT_SIZE_2X);
delay(500);
display.printFixedN (0, 48, " ", STYLE_NORMAL, FONT_SIZE_2X);
delay(250);
display.printFixedN (0, 48, "TimeERROR", STYLE_NORMAL, FONT_SIZE_2X);
delay(500);
display.printFixedN (0, 48, " ", STYLE_NORMAL, FONT_SIZE_2X);
delay(250);
break;
}
digitalWrite(valveRelay, HIGH);
break;
}
}
digitalWrite(pumpRelay, HIGH);
int delayReading = analogRead(delayPin);
long pumpDelayPeriod = map(delayReading, 1023, 0, 1000, 60000);
long randomDelay = random(1000, pumpDelayPeriod);
delay(randomDelay);
checkButton();
randomValve = random(100, pumpPeriod/.75);
Serial.print("random valve "); // prints fine
Serial.println(randomValve);
digitalWrite(valveRelay, LOW);
delay(randomValve);
digitalWrite(valveRelay, HIGH);
int valveReading = analogRead(valvePin);
long valveTimePeriod = map(valveReading, 1023, 0, 1000, 30000);
longDelay = random(500, valveTimePeriod);
delay(longDelay);
Serial.print("long delay "); // prints fine
Serial.println(longDelay);
oldPumpPeriod = pumpPeriod;
display.printFixedN (0, 48, " ", STYLE_NORMAL, FONT_SIZE_2X);
}
any idea's on what could be causing something like this to happen?
I also just discovered that if i remove the Serial.print("randomPump "); and only try to do Serial.println(randomPump); then doing that completely glitches the code and messes up the code farther on the page where randomPump is called.


