% Author - Prashant Patil % 12/16/2011 % sends the character p throgh serial port and recieve it back ( you need % to burn the serial code in uC) % Find a serial port object. obj1 = instrfind('Type', 'serial', 'Port', 'COM5', 'Tag', ''); % Create the serial port object if it does not exist % otherwise use the object that was found. if isempty(obj1) obj1 = serial('COM5'); else fclose(obj1); obj1 = obj1(1) end % Connect to instrument object, obj1. fopen(obj1); % Configure instrument object, obj1. set(obj1, 'BaudRate', 1200); set(obj1, 'Terminator', {126,126}); set(obj1, 'StopBits', 2.0); data = query(obj1,'p');