how to interface 8051 and matlab
1 次查看(过去 30 天)
显示 更早的评论
im trying to turn led on and off by sending an 'o' for on and 'f' for off serially from matlab to (at89c51) the problem is nothing is happening and both my cods are error free. i have never done serial communication before so i have little idea of what im doing wrong. please help! here are my codes:
for 8051
org 100h
mov tmod,#20h
mov th1,#-3
mov scon,#50h setb tr1
again: jnb ri,here
mov a,sbuf
cjne a,#'o',ledoff
setb p2.0
ledoff: clr p2.0
clr ri
sjmp again
end
.................................................. ..................................................
for matlab:
>> s = serial('COM1','baudrate',9600);
>> fopen(s)
>> a=inputdlg('enter o to turn led on and f to turn it off','s');
>> fprintf(s, 'a');
>> fclose(s)
>> clear s
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!