Here's my attempt to modify the code from gadelhas's post above. My FORM has two push buttons, one opens the COM1 PORT the other closes it. I can't get it to show any data in the ListBox1 though from the PIC. The PIC code (shown below) outputs a RANDOM BYTE.
Any Ideas? Anyone?
Code:
Public Class Form1
Dim WithEvents SerialPort1 As New IO.Ports.SerialPort
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SerialPort1.PortName = "COM1"
SerialPort1.Parity = IO.Ports.Parity.None
SerialPort1.BaudRate = 2400
SerialPort1.DataBits = 8
SerialPort1.StopBits = 1
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If SerialPort1.IsOpen = False Then SerialPort1.Open()
If SerialPort1.IsOpen = True Then MsgBox("com1 port opened sucessfully")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If SerialPort1.IsOpen = True Then SerialPort1.Close()
If SerialPort1.IsOpen = False Then MsgBox("com1 port closed sucessfully")
End Sub
Private Sub DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Dim recepcao As String
recepcao = SerialPort1.ReadExisting
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
SerialPort1.Write(ListBox1.Text)
PIC code:
Code:
A VAR WORD
X VAR WORD
Y VAR WORD
Z VAR BYTE
main:
Random A
Y = A * 100
X = DIV32 25700
LET Z = X
SEROUT2 PORTC.3, 16780, [DEC z, 10, 13]
pause 4000
GOTO MAIN
Bookmarks