URGENT Help with this project (please!) Urgent!

i think the code in post #19 should work

these conditional prints may make it easier to see the events

void loop() {
    // Sensor detects white patch (active LOW on many modules)
    if (digitalRead(sensorPin) == LOW) {
        counter = countMax;            // Reset counter whenever white patch detected
        digitalWrite(relayPin, HIGH);  // Relay ON

        if (LOW == digitalRead (relayPin))
            Serial.println("Wheel moving → Relay ON");
    }
    else {
        if (counter > 0) {
            if (countMax == counter)
                Serial.println("Wheel stopped");
            counter--;
        }
        else {
            digitalWrite(relayPin, LOW);  // Relay OFF
            if (HIGH == digitalRead (relayPin))
                Serial.println("Relay OFF");
        }
    }

    delay(1);
}