Place a goto Main at the end, and change ["255"] to [255].
Code:Main: SerIn Si,4,[255],pinstate IF pinstate=1 Then GoSub Relayon Else GoSub Relayoff EndIF GOTO Main ' <-- forgot this Relayon: High RELAY Return Relayoff: Low RELAY Return
Place a goto Main at the end, and change ["255"] to [255].
Code:Main: SerIn Si,4,[255],pinstate IF pinstate=1 Then GoSub Relayon Else GoSub Relayoff EndIF GOTO Main ' <-- forgot this Relayon: High RELAY Return Relayoff: Low RELAY Return
tq for the reply..actually there are problem appear after i tried the code u have given..when i'm sending '0' from VB and after that send "1" to th PIC.the relay does not "on".
the problem also appear after once i "on" and "off" the relay, and then i want to "on" again the relay is not "on"
how do you interface your PIC to the PC? resistor i guess, wich value? 1k-10K is fair enough. geater than 10K seems to cause erratic behavior in some case.
Could also be a hardware problem as we see often.. psu filtering or else.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
The PIC may not supply enough current to trigger your relay. Put an LED in its place and make sure it is going on and off.
For development i always use an LED to make sure my output is going on and off. Then I usually have to drive the relay with a transistor. I haven't found a relay yet I could directly drive.
forget me...i was wrong
Last edited by mister_e; - 27th June 2006 at 16:50.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks