MATLAB put LED on serial port

I am working on MATLAB, I only want to connect an LED and a resistor to the serial port.

When a certain action occurs in my program, the LED should turn on.

What I did but nothing happened:

S   = serial( 'com1' );
fid = fopen( s );                         # ... 've checked the s vs. S ?

      

+3


source to share


1 answer


You should be able to control strings DTR

and RTS

(on DB-9 connectors on pins 4 and 7 respectively) from MATLAB. According to the link, serial port objects have properties DataTerminalReady

and RequestToSend

that can be toggled. For example,

S = serial('com1');
for ii = 1:5
    set(S, 'RequestToSend', 'on');
    pause(1)
    set(S, 'RequestToSend', 'off');
    pause(1)
end

      



the LED connected to the pin will flash RTS

five times.

0


source







All Articles