Baud rate?

Hi for some reason the serial monitor is outputting gibberish. I have an external power supply 9V and a relay that powers the motor, as well as an ultrasonic sensor. Here is my code, I appreciate all the help!

const int motor = 8;
const int trig = 2;
const int echo = 3;
// defines variables
long duration;
int distance;
void setup() {
  pinMode(trig, OUTPUT); // Sets the trigPin as an Output
  pinMode(echo, INPUT); // Sets the echoPin as an Input
  pinMode(motor, OUTPUT);
  Serial.begin(9600); // Starts the serial communication
}
void loop() {
  // Clears the trigPin
  digitalWrite(trig, LOW);
  delayMicroseconds(20);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trig, HIGH);
  delayMicroseconds(100);
  digitalWrite(trig, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echo, HIGH);
  // Calculating the distance
  distance = duration * 0.034 / 2;
  // Prints the distance on the Serial Monitor
  Serial.print("Distance: ");
  Serial.println(distance);

  if (distance > 8) {
    digitalWrite(motor, HIGH);

  }
    else {
      digitalWrite(motor, LOW);
    }
  }

Toothpastecodesonic.ino (980 Bytes)

What do you have the baud rate of the Serial monitor set to ?

I have both the monitor and arduino set to 9600

Try running the sketch with the motor relay disconnected from the output pin that controls it.

From the sounds of it, it is a similar problem to what I'm having with my serial monitor output for a PWM from RC transceiver reader. Could you add an image of the gibberish it is outputting?

{ "Ports": [], "Network": true }
{ "Ports": [ { "Name": "COM3", "SerialNumber": "75735323430351617142", "DeviceClass": "", "IsOpen": false, "IsPrimary": false, "Baud": 0, "BufferAlgorithm": "", "Ver": "1.1.251", "NetworkPort": false, "VendorID": "0x2341", "ProductID": "0x0043" } ], "Network": false }
list

Any you guys know what this means?