Trouble with code

hello everyone i’ve tried to make a little something with soil humidity (i snooped around to make my “own” code) and it just doesn’t work i’m wondering why it isn’t if someone could help me out.

int maximumMoistureLevel;
int currentMoistureLevel;

void moistureDetection() {
  if (currentMoistureLevel / maximumMoistureLevel < 0.1) {
    Serial.println("low moisture");
  } else if (currentMoistureLevel / maximumMoistureLevel <= 0.5 && currentMoistureLevel / maximumMoistureLevel > 0.1) {
    Serial.println("average moisture");
  } else {
    Serial.println("high moisture");
  }
}

void setup() {
  pinMode(A0, INPUT);
  maximumMoistureLevel = analogRead(A0);
}

void loop() {
  currentMoistureLevel = analogRead(A0);
  moistureDetection();
  delay(100);
  Serial.println(currentMoistureLevel);
}

Just code cannot diagnose problems. @Alphabricot Please attach the .fzz sketch file

Doesn’t work? What does it do, what do you expect it to do?

For starters, I would suggest keeping track of the last report moisture level range and value message. You probably don’t need to send a new message every 100 ms. Maybe every 10 minutes, or immediately if it changes. Make that ‘changes enough’. Noise can have reading ‘bounce’ around the actual value.

I do not see why you are seting the maximum level to the initial reading. Why is the first reading going to be the maximum?

The else if does not need to check the low limit again. If it was low, the initial check would have reported that, and the next check would not happen. Technically there is an error in that code. If the ratio is exactly 0.1, it will get reported as high moisture.