我已做了一个8052的控制, 目的是P1.0~P1.3 收SENSOR OUTPUT +5V, 而P2.0~2.3能自动相应而着灯及经过RS232去电脑, 现在最重要是不知写的KEIL C CODE 可以将SIGNAL傅送到电脑的VB6.0显示灯上?? 请各位帮忙!!
程式如下:
#include<REGX52.H>
#include<STDIO.H>
main()
{
TMOD=0x20;
TH1=230;
TL1=230;
TR1=1;
SCON=0x70;
while(1)
{
RI=0;
TI=0;
SBUF=P1 | 0xf0;
while(TI==0);
while(RI==0);
if(SBUF==0xfe)
P1=0x3f;
else if(SBUF==0xfd)
P1=0xcf;
else if(SBUF==0xfb)
P1=0x0f;
else if(SBUF==0xf7)
P1=0xff;
}
}
另外我的VB6.0 程式如下:
Private Sub Command5_Click()
tex1.Text = "连线中"
MSComm1.Output = "0"
delayms 100
buf = MSComm1.Input
If buf = "2" Then
LOAD1.FillColor = RGB(0, 255, 0)
LOAD2.FillColor = RGB(0, 255, 0)
LOAD3.FillColor = RGB(0, 255, 0)
LOAD4.FillColor = RGB(0, 255, 0)
Else
tex1.Text = "连线失败"
End If
End Sub
Private Sub Command6_Click()
On Error Resume Next
msg = "您确定要结束本程式吗 ?"
code = 65
Title = "关闭程式"
return_value = MsgBox(msg, code, Title)
If return_value = 1 Then
Command5_Click
MSComm1.PortOpen = False
End
End If
End Sub
Private Sub Command7_Click()
On Error GoTo OUTPUTERR
Dim i As Integer, iFile As String
iFile = "d:\test.txt"
Do While Dir(iFile) <> "" ..
访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容