Relay Problem

I am trying to design a project where an ultrasonic sensor detects the distance from an object and if less than a certain value it operates a relay.
With the relay connected to Digital pin 10 the IN pin of the relay always stays high, whether it is above or below the value set, hence the relay does not operate.
I am using a 5v relay module.

// ---------------------------------------------------------------------------
// This example shows how to use NewPing's ping_timer method which uses the Timer2 interrupt to get the
// ping time. The advantage of using this method over the standard ping method is that it permits a more
// event-driven sketch which allows you to appear to do two things at once. An example would be to ping
// an ultrasonic sensor for a possible collision while at the same time navigating. This allows a
// properly developed sketch to multitask. Be aware that because the ping_timer method uses Timer2,
// other features or libraries that also use Timer2 would be effected. For example, the PWM function on
// pins 3 & 11 on Arduino Uno (pins 9 and 11 on Arduino Mega) and the Tone library. Note, only the PWM
// functionality of the pins is lost (as they use Timer2 to do PWM), the pins are still available to use.
// NOTE: For Teensy/Leonardo (ATmega32U4) the library uses Timer4 instead of Timer2.
// ---------------------------------------------------------------------------
#include <NewPing.h>

#define TRIGGER_PIN  12  // Arduino pin tied to trigger pin on ping sensor.
#define ECHO_PIN     11  // Arduino pin tied to echo pin on ping sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
int relayPin= 10; //Arduino pin tied to relay sense pin
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

unsigned int pingSpeed = 50; // How frequently are we going to send out a ping (in milliseconds). 50ms would be 20 times a second.
unsigned long pingTimer;     // Holds the next ping time.

void setup() {
  Serial.begin(9600); // Open serial monitor at 115200 baud to see ping results.
  pingTimer = millis(); // Start now.
  
}

void loop() {
  // Notice how there's no delays in this sketch to allow you to do other processing in-line while doing distance pings.
  if (millis() >= pingTimer) {   // pingSpeed milliseconds since last ping, do another ping.
    pingTimer += pingSpeed;      // Set the next ping time.
    sonar.ping_timer(echoCheck); // Send out the ping, calls "echoCheck" function every 24uS where you can check the ping status.
  }
  // Do other stuff here, really. Think of it as multi-tasking.
  if(sonar.ping_result / US_ROUNDTRIP_CM <10){
    digitalWrite(relayPin,HIGH);
  }else{
    digitalWrite(relayPin,LOW);
  }
}

void echoCheck() { // Timer2 interrupt calls this function every 24uS where you can check the ping status.
  // Don't do anything here!
  if (sonar.check_timer()) { // This is how you check to see if the ping was received.
    // Here's where you can add code.
   
    
    
    Serial.print("Ping: ");
    Serial.print(sonar.ping_result / US_ROUNDTRIP_CM); // Ping returned, uS result in ping_result, convert to cm with US_ROUNDTRIP_CM.
    Serial.println("cm");
  }
  // Don't do anything here!
}

What am I doing wrong?

pinMode(relayPin,OUTPUT); // put this in setup, see if this works. If not, post link to the relay module.

What am I doing wrong?

Simply switching a pull up resistor on or off isn't likely to operate a relay, is it?

Dr AZZY- Thanks that worked, except it had to go after serialBegin. In setup it errored. AWOL - Your comments were hardly constructive!

Why use a relay at all. They went out of date in the 1960's. Look up transistor!. And Yes AWOL's comment was useful. And your comment about id needing to go after Serial.begin just tells us you are doing something stupid.

Mark