Skip to content

Instantly share code, notes, and snippets.

@GiovanniBalestrieri
Created July 28, 2015 00:09
Show Gist options
  • Save GiovanniBalestrieri/487589fa12173a913cd2 to your computer and use it in GitHub Desktop.
Save GiovanniBalestrieri/487589fa12173a913cd2 to your computer and use it in GitHub Desktop.
Snippet 1 - Matlab Arduino serial communication
% XBee expects the end of commands to be delineated by a carriage return.
xbee = serial(port,'baudrate',9600,'terminator','CR','tag','Quad');
set(xbee, 'TimeOut', 5); %I am willing to wait 1.5 secs for data to arive
% I wanted to make my buffer only big enough to store one message
set(xbee, 'InputBufferSize', 390 )
% Before you can write to your serial port, you need to open it:
fopen(xbee);
disp('Serial port opened');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment