我用VB做了一个上位机想用来控制51单片机,模拟了数值增加,减少和复位键,但是上位机上的数值增加键和减少键按一次,单片机的数值会不断增加,再按别的也没反应,复位键也只能按一次,按别的也都没反应请问是什么问题? |
补充内容 (2018-5-8 09:59):
下面是我上位机程序
Private Sub Command1_Click()
strBuff = "1"
MSComm1.Output = strBuff
End Sub
Private Sub Command2_Click()
strBuff = "2"
MSComm1.Output = strBuff
End Sub
Private Sub Command3_Click()
strBuff = "3"
MSComm1.Output = strBuff
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Load()
Label1.Cap
tion = "-----"
Label2.Caption = "-----"
Command1.Caption = "增加"
Command2.Caption = "减少"
Form1.WindowState = 2 '界面设置为最大
MSComm1.Settings = "9600,n,8,1"
MSComm1.OutBufferSize = 2 '设置MSComm1发送缓冲区为2字节
MSComm1.OutBufferCount = 0 '清除发送缓冲区
MSComm1.CommPort = 3 '指定使用com4
MSComm1.PortOpen = True '打开接口
End Sub
Private Sub MSComm1_OnComm()
Text1.Text = MSComm1.Input
Text2.Text = MSComm1.Input
End Sub