PDA

View Full Version : PicBasic SERIN



azra01
- 8th January 2010, 19:16
Hello!

How to turn on LED with PIC16F84A when I send some date from computer

So, how to use the command SERIN?

Thanks!

Archangel
- 9th January 2010, 01:56
Hello Azra01,
UnTested Sample:


PortA = %00000000 'all outputs low
PortB = %00000000 'all outputs low
TrisA = %00000000 'All as outputs
TrisB = %00000001 ' B.0 as input all others as outs


include"modedefs.bas" ' includes aliases for modes
b0 var byte
dummy var byte
mainloop:

'from the manual except I named the port to be used <> 1
serin PortB.0, n2400,["A"],B0 'waits for ASCII A then saves next data
' not exactly from the manual but close
branch B0, [dog, cat, fish, mainloop] 'same as if then spaghetti

dog: 'here is where the work gets done, in the subs
porta.0 = 1
goto mainloop

cat: 'here is where the work gets done, in the subs
porta.0 = 0
goto mainloop

fish: 'here is where the work gets done, in the subs
for dummy = 0 to 9
portb.1=1
pause 500
portb.1 = 0
pause 500
next dummy

goto mainloop

So send out an ASCII "A" and the number 1 and it jumps to DOG
A and 2 ,and it jumps to CAT . . .
EDIT: just checked it, compiles . . . should run . . .