Mega DC motor problem

i have an arduino mega with a 5V geared dc motor switched by means of a relay. The mega switches this motor on and off based on the state of two optical sensors and two capacitive sensors. if the sensors senses an object it operates a servo motor which agitates the object and then places the object to the right or left based on the readings. Now the problem i am having is the switching of the DC motor. i have the board and the motor connected to seperate sources with a relay switchin the motor on and off. Every time the board switches the motor on, the board starts bugging out and doing things i do not want it to do. please help me with this problem.

here is my code:

#include <Servo.h>

Servo myservo;
int DCmotor = 22;
int sens3 = 43;
int sens4 = 45;
int sens3d = 0;
int sens4d = 0;
int sum = 0;
int pos = 50;
volatile int sensed = LOW;

void setup()
{
pinMode(DCmotor, OUTPUT);
myservo.attach(7);
pinMode(sens3,INPUT);
pinMode(sens4,INPUT);
attachInterrupt(5, move, LOW);
attachInterrupt(4, move, LOW);
attachInterrupt(3, move, HIGH);
attachInterrupt(2, move, HIGH);
}

void loop()
{

while(sensed == HIGH)
{
digitalWrite(DCmotor,LOW);
for(pos = 60; pos < 100; pos+=1)
{
myservo.write(pos);
delay(10);
}
delay(1000);
sens3d = digitalRead(sens3);
sens4d = digitalRead(sens4);
sum = sens3d + sens4d;
if(sum == 0){
for(pos = 100; pos < 140; pos += 1)
{
myservo.write(pos);
delay(15);
}
for(pos = 140; pos>=100; pos-=1)
{
myservo.write(pos);
delay(15);
}
}
if(sum == 2){
for(pos = 100; pos > 30; pos-=1)
{
myservo.write(pos);
delay(15);
}
for(pos = 30; pos <= 100; pos+=1)
{
myservo.write(pos);
delay(15);
}
}
digitalWrite(DCmotor,HIGH);
interrupts();
sensed = LOW;
}
}

void move()
{
sensed = HIGH;
noInterrupts();
}

Without trying to pick through your code - where does the relay get its power from? if it’s being driven directly from an Arduino pin then it may be causing your problems. Does it have a diode? how much current does the coil draw?

and doing things i do not want it to do

Drinking?
Smoking?
Going out with the wrong kind of girls?

Seriously, this doesn't help us at all - you must describe what you do want it to do.

Please don't cross-post - it just wastes time, and when posting code, please use the "code" (#) button in the editor.
If you go back to your original post, click on "modify", then highlight the code, then click on the "#" button in the editor.