Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

VB6 Error with serial communication

Status
Not open for further replies.

lloydi12345

Member
I'm trying serial communication with PIC16f877a but the problem is I'm having problem on my software. I based my software from this site

Visual Basic - Communicating With The Microcontroller

everything is exactly the same. I uploaded an image which shows the error.
 

Attachments

  • Capture.JPG
    Capture.JPG
    72 KB · Views: 412
Last edited:
I build my own ericgibbs
hi.
You may have missed out a piece of code.

It should be like this, make sure you have all the 'components' on the form

Option Explicit

Private Sub cmdSend_Click()
Dim PinNumber As Long
Dim PinState As Long

' Get Pin Number
PinNumber = cboPinNumber.ListIndex

' Get Pin State
If optState(0).Value = True Then
PinState = 0
Else
PinState = 1
End If

' Send Out Data
MSComm1.Output = Chr$(255) & Chr$(PinNumber) & Chr$(PinState)

End Sub

Private Sub Form_Load()
Dim Pins As Long

' Add the pin numbers 0 to 15 to cboPinNumber
For Pins = 0 To 15
cboPinNumber.AddItem CStr(Pins)
Next Pins

' Default to Pin 0 being selected
cboPinNumber.ListIndex = 0

' Default to optState(0) being selected
optState(0).Value = True

' Use COM1
MSComm1.CommPort = 1

' 2400 baud, no parity, 8 data bits, 1 stop bit
MSComm1.Settings = "2400,N,8,1"

' Make sure DTR line is low to prevent Stamp reset
MSComm1.DTREnable = False

' Open the port
MSComm1.PortOpen = True

End Sub


Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub
 

Attachments

  • 000esp01.gif
    000esp01.gif
    3.8 KB · Views: 216
Thank you mdanh2002 and ericgibbs for the help. I downloaded the whole project instead to have no problem. I got it now working with no problem. I think I just missed something on my own made form. Thank you again ;)
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top