PDA

View Full Version : send data from pc(Visual Basic) to pic16f877a through serial port(DB9)



texas5
- 24th August 2008, 11:33
hi.i want to send data from pc(Visual Basic) to pic16f877a through serial port(DB9).all the hardware have been setup(i'm using max232).can someone help me for the coding part(both code for VB and pic).just a simple code(LED blinking) for testing my pic circuit.

HenrikOlsson
- 24th August 2008, 16:18
Have a look here (http://www.rentron.com/VisualBasic.htm)

texas5
- 24th August 2008, 20:01
thanx man...

texas5
- 25th August 2008, 03:51
here's the code for micro controller:

PinNumber var byte
PinState var byte

Main:

' Use the programming port to receive
' data at 2400 baud
' Wait for the synch byte (255) and then
' get the PinNumber and PinState
Serin 16,16780,[WAIT(255),PinNumber,PinState]

' If PinState=0 Then go to GoLow
' otherwise go to GoHigh
Branch PinState,[GoLow,GoHigh]
Goto Main


' Set The pin low
GoLow:
LOW PinNumber
Goto Main


' Set the pin high
GoHigh:
HIGH PinNumber
Goto Main
END

i have problem when compile it....the 'Serin 16,16780,[WAIT(255),PinNumber,PinState]' appear as bad expression...why is it???

HenrikOlsson
- 25th August 2008, 06:14
Hi,


i have problem when compile it....the 'Serin 16,16780,[WAIT(255),PinNumber,PinState]' appear as bad expression...why is it??? That's probably because WAIT isn't supported by the SERIN command, you'd need to change that to SERIN2 i think.

Archangel
- 25th August 2008, 06:50
Or might be because PIN 16 is not a valid pin , funny I have never used PINs always used PortA, PortB etc . . less confusing I guess . . . anyway only 0-15 are valid: SEC. 4.11. PINS

texas5
- 25th August 2008, 07:38
so what is your suggestion joe s.????

mackrackit
- 25th August 2008, 08:16
HenrikOlsson and Joe are saying change your code from


Serin 16,16780,[WAIT(255),PinNumber,PinState]

to


SERIN2 PORT?.?,16780,[WAIT(255),PinNumber,PinState]

Seems to work much better using for example:
PORTC.3
instead of
PIN?

rhino
- 25th August 2008, 21:45
texas5 -
Please note the information on Bruce's website prior to the code for this example:

The Microcontroller Part
For simplicity I am going to use a Basic Stamp II to receive the data and act accordingly to the data. You will need to hook up the Basic Stamp II just like you are going to program it and use the programming port (pin 16) for communications. Program the Basic Stamp II with the following code... That's probably where there is some confusion.

texas5
- 27th August 2008, 21:07
emmmmm....thanx for the information....