is this program is writ??? replr me

hi am trying to make a robot which will be making a square and ia m using ir sensor which will be there when it goes high it should stop the bot this is the code pls help me i anna to know the code is writ or not ??? pls check the code which i hav written

int motor_1_terminal_1 = 5;
int motor_1_terminal_2 = 6;
int motor_2_terminal_1 = 10;
int motor_2_terminal_2 = 11;
i
void setup()
{ Serial.begin(9600);
pinMode(motor_1_terminal_1, OUTPUT);
pinMode(motor_1_terminal_2, OUTPUT);
pinMode(motor_2_terminal_1, OUTPUT);
pinMode(motor_2_terminal_2, OUTPUT);
attachInterrupt(2,stopmotor,CHANGE);
}
void stopmotor()
{
analogWrite(motor_1_terminal_1,0);
analogWrite(motor_1_terminal_2,0);
analogWrite(motor_2_terminal_1,0);
analogWrite(motor_2_terminal_2,0);
}
void loop()
{
analogWrite(motor_1_terminal_1,255);
analogWrite(motor_1_terminal_2,0);
analogWrite(motor_2_terminal_1,255);
analogWrite(motor_2_terminal_2,0);
delay(1000);
analogWrite(motor_1_terminal_1,0);
analogWrite(motor_1_terminal_2,255);
analogWrite(motor_2_terminal_1,0);
analogWrite(motor_2_terminal_2,233);
delay(1000);
}

sab.ino (927 Bytes)

nothinghere:
hi am trying to make a robot which will be making a square and ia m using ir sensor which will be there when it goes high it should stop the bot this is the code pls help me i anna to know the code is writ or not ??? pls check the code which i hav written

int motor_1_terminal_1 = 5;
int motor_1_terminal_2 = 6;
int motor_2_terminal_1 = 10;
int motor_2_terminal_2 = 11;

void setup()
{ Serial.begin(9600);
pinMode(motor_1_terminal_1, OUTPUT);
pinMode(motor_1_terminal_2, OUTPUT);
pinMode(motor_2_terminal_1, OUTPUT);
pinMode(motor_2_terminal_2, OUTPUT);
attachInterrupt(2,stopmotor,CHANGE);
}
void stopmotor()
{
analogWrite(motor_1_terminal_1,0);
analogWrite(motor_1_terminal_2,0);
analogWrite(motor_2_terminal_1,0);
analogWrite(motor_2_terminal_2,0);
}
void loop()
{
analogWrite(motor_1_terminal_1,255);
analogWrite(motor_1_terminal_2,0);
analogWrite(motor_2_terminal_1,255);
analogWrite(motor_2_terminal_2,0);
delay(1000);
analogWrite(motor_1_terminal_1,0);
analogWrite(motor_1_terminal_2,255);
analogWrite(motor_2_terminal_1,0);
analogWrite(motor_2_terminal_2,233);
delay(1000);
}

First, use CODE tags, not QUOTE tags.
Second, what Arduino are you using? If is anything other than a Arduino Mega or Arduino Mega related, then your interrupt address should not be 2, it should be 0 or 1.

Do you have a link to your sensor?

This will turn just slightly, is that what you want, or something sharper?

analogWrite(motor_1_terminal_1,0);
analogWrite(motor_1_terminal_2,255);
analogWrite(motor_2_terminal_1,0);
analogWrite(motor_2_terminal_2,233);

i am using Arduino Duemilanove
i want to use my passive infrared sensor as interrupt. when my pir sensor goes high it should stop the wrking arduinoand when it comes to zero it should contiue it process

Interrupt pins:
Pin 2 = interrupt 0
Pin 3 = interrupt 1

Your IR sensor, don't you need to do some calculations with the data from it? I don't know if it can be tied into an interrupt and still work. Post a link to your particular IR sensor.

http://www.sproboticworks.com/ir-sensors/ir-sensors/ir-sensor-module-da.html

i am using this sensor ... can we give sensor as interrupt???
i want to give the sensor as the interrupt

That's a good sensor, yes, you can use interrupts with it. Look at post above to see the pins and interrupts.

NOTE: I don't think you want it as CHANGE, you may want it as HIGH or RISING.

thank u for telling ...... could u give me the correctb code

I told you what to change, you can correct the code.