![]() |
|
Tài trợ cho PIC Vietnam |
Giao tiếp cổng COM và LPT RS232, RS485 và LPT là những giao tiếp cơ bản và kinh điển khi mới học về vi điều khiển... |
|
Ðiều Chỉnh | Xếp Bài |
![]() |
#33 | |
Nhập môn đệ tử
Tham gia ngày: Oct 2011
Bài gửi: 1
: |
Trích:
Option Explicit Dim Send_Data As String Dim ket_noi As Integer Dim Hbyte As Integer Dim Lbyte As Integer Dim arr() As Byte Private Sub cmdclear_Click() Text1.Text = "" Text2.Text = "" End Sub Private Sub cmdClose_Click() Unload Me End Sub Private Sub Form_Load() 'If MSComm1.PortOpen Then MSComm1.PortOpen = False 'With MSComm1 '.CommPort = 1 '.Settings = "9600,n,8,1" '.RThreshold = 3 'so byte truyen '.PortOpen = True 'End With If MSComm1.PortOpen Then MSComm1.PortOpen = False MSComm1.CommPort = 1 MSComm1.Settings = "9600,n,8,1" MSComm1.RThreshold = 3 MSComm1.InputMode = comInputModeBinary MSComm1.InBufferCount = 0 MSComm1.PortOpen = True Text1.Text = "" Text2.Text = "" End Sub Private Sub cmdSend_Click() Send_Data = Trim(Text1.Text) Hbyte = Send_Data \ 256 Lbyte = Send_Data Mod 256 MSComm1.Output = Chr(Hbyte) & Chr(Lbyte) & Chr$(13) 'MSComm1.Output = Send_Data & Chr$(13) End Sub Private Sub MSComm1_OnComm() If MSComm1.CommEvent = comEvReceive Then Dim rcv If MSComm1.CommEvent = comEvReceive Then arr() = MSComm1.Input 'If (arr(2) = 255) Then Text2.Text = arr(0) * 256 + arr(1) 'End If End If End If End Sub |
|
![]() |
![]() |
Tags |
forms!nhap!vao = x |
|
|
![]() |
||||
Ðề tài | Người gửi | Chuyên mục | Trả lời | Bài mới |
Giao tiếp RS232 trên PC | ngohaibac | Giao tiếp cổng COM và LPT | 193 | 18-02-2025 09:11 AM |
Cho hỏi về giao tiếp RS232 của PIC16F877A | enti | Giao tiếp cổng COM và LPT | 31 | 25-03-2016 10:14 PM |
Giao tiếp RS232 trên PC qua Matlab | ngohaibac | Giao tiếp cổng COM và LPT | 47 | 18-11-2015 03:51 PM |
cần mua bộ thu GPS có giao tiếp RS232 | kienvq | Tìm mua sản phẩm | 15 | 17-03-2011 11:25 PM |
Help! Dùng C để giao tiếp RS232 | dandiennang | Các ngôn ngữ lập trình khác (CCS C, HT PIC,...) | 6 | 15-03-2009 06:41 PM |