Help on Fire FIghting robot

Hi,
We are doing a project on fire fighting using arduino and Matlab. The Matlab sends the pwm values to the arduino(via Serial port). Then the motor controls will be done with the help of arduino. The matlab continously sends the data.

function [] = main()
vidobj = videoinput('winvideo', 1, 'RGB24_320X240');

function [row,col,intensity] = track()

frame = getsnapshot(vidobj);
frame = rgb2gray(frame);
flame = (frame  >=  (0.80 * double(max(frame(:)))));
props = regionprops(bwlabeln(flame), 'Area', 'Centroid');
area = [props.Area];
[num_pixels, index] = max(area);
threshold = 5;
if (num_pixels > threshold)
    row = props(index).Centroid(2);
    col = props(index).Centroid(1);
else 
   row = NaN;
   col = NaN;
end
col=int16(col);
row=int16(row);
if row== 0 || col==0
    intensity=0;
else
    intensity=frame(row,col);
end
end 

function [] = pwmset(d1,d2,d3,d4)

fwrite(s,'s');
fwrite(s,d1);
fwrite(s,d3);
fwrite(s,d2);
fwrite(s,d4);
end

s=serial('COM1');
fopen(s);
vidobj = videoinput('winvideo', 1, 'RGB24_320X240');


preview(vidobj);

flag=0;
transflag=0;
while flag == 0
 [a,b,c]=track();
   if c<230  
     if transflag == 0
         pwmset('f',char(120),'b',char(120));
         
         
         pause(.25);
         pwmset('f',char(0),'f',char(0));
     end
  else
   flag=1;
   pwmset('f',char(0),'f',char(0));
   transflag=1;
   end
end
while transflag ==1
   [a,b,c]=track();
    if c >220 %Threshhold
     if b>210
        pwmset('f',char(120),'b',char(120));
        pause(.25);
        pwmset('f',char(0),'f',char(0));
     end
    if b<100
        pwmset('b',char(120),'f',char(120));
        pause(.25);
        pwmset('f',char(0),'f',char(0));
    end
    if b>100
        if b<210
        pwmset('f',char(120),'f',char(120));
        pause(.25);
        pwmset('f',char(0),'f',char(0));
        end 
    end
    end
    if c < 200 % Thresh hold modify
        pwmset('f',char(0),'f',char(0));
        transflag = 0;
    end
end
fwrite(s,'r');
fclose(s);
delete(vidobj)
clear vidobj
end

the above is the matlab code for fire detection…

i want the code for arduino to control the motors by reading the serial data sent by matlab…

http://arduino.cc/en/Reference/Serial

What type of motors? How are you connecting them?

kantharaj26: We are doing a project ...

i want the code for arduino

So, are you doing the project, or are you asking arduino.cc to do it for you? I assume you understand that the Arduino is capable of reading from a serial port and controlling various types of motor. There is plenty of documentation about both those things. Where have you got in trying to solve the problem yourself, before asking arduino.cc to implement it for you?

Goodmorning. We are also planning to make a Fire Fighting Robot using Arduino. Will it be advisable to use Two arduinos, one as a transmitter and one as a receiver to drive the robot? Thanks a lot and Godbless. :)

Will it be advisable to use Two arduinos, one as a transmitter and one as a receiver to drive the robot?

Without more details, it's hard to tell.