Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %Delete previous connections
- delete(instrfind({'Port'},{'/dev/tty.usbmodem621'}));
- %Create a serial connection
- s = serial('/dev/tty.usbmodem621','BaudRate',9600,'Terminator','CR/LF');
- warning('off','MATLAB:serial:fscanf:unsuccessfulRead');
- %Open Port
- fopen(s);
- %Initialize the variables
- Nvalues=100; %Number of values we want to read
- m1=zeros(1,Nvalues);
- i=1;
- k=0;
- while k<Nvalues
- %Read the serial port
- a = fscanf(s,'%f.%f')';
- m1(i)=a(1);
- %Draw the figure
- figure(1);
- plot(m1);
- %Increment the counter
- i=i+1;
- k=k+1;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement