-
Notifications
You must be signed in to change notification settings - Fork 0
/
shutter_laptop.asv
executable file
·43 lines (36 loc) · 1.11 KB
/
shutter_laptop.asv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
%==================Control Arudino Shutter with Matlab====================%
% Usage:
% 1. Initialize serial port device: baudrate, 57600
% 2. Send command to serial port to contro shutter:
% fprintf(serial_object, '%s', '1') % open shutter
% fprintf(serial_object, '%s', '0') % close shutter
% 3. Close and release serial object
%
% Ver 0.1 20190905 by H.F
%=========================================================================%
% ser_st = serial('COM5', 'BaudRate', 57600);
% fopen(ser_st);
%
fprintf(ser_st, '%s', '1'); % open shutter
fprintf(ser_st, '%s', '0'); % close shutter
% fprintf çš„é»˜è®¤æ ¼å¼ä¸º %s\n, éœ?¦å°†ç»ˆæ¢ç¬¦é…置为空 ã€?
% for i = 1:100
% fprintf(ser_st, '%s', '1');
% pause(1);s
% fprintf(ser_st, '%s', '0');
% pause(1);
% end
t_last = clock;
on = 0.1; % min
off = 0.1; % min
for i = [1:3]
fprintf(ser_st, '%s', '0');
'Now close shutter'
while (clock - t_last < 60*off ) % off time
end
t_last = clock;
fprintf(ser_st, '%s', '1');
'Now open shutter'
while (clock - t_last < 60*on ) % on time
end
end