Like I said in the code above, if your ADCON and/or ANSEL bits aren't set right, chances are anything you try to do digitally with an analog capable pin won't work right.Code:INCLUDE "bs2defs.bas" relay var portb.3 '<-----?????? Relay VAR b3 'relay number storage variable stat var portb.4 '<------??????stat VAR b4 'relay status ON/OFF variable trisa = $10 : trisb = 0 : PAUSE 100 loop: SERIN porta.4,396,[ WAIT [254],relay,stat] 'serial data in on PortA.4 '--note for line above...Is porta.4 an optional analog port? Are the correct ADCON bits set? '---depends on the PIC you're using....which we don't know, in this case, they're not..... branch relay,[outr1,outr2,outr3,outr4,outr5,outr6,outr7,outr8,outr9,outr10,outr11,outr12] GOTO loop outr1: if stat = 1 then high 0 else low 0 endif goto loop outr2: IF stat = 1 THEN high 1 else low 1 endif goto loop outr3: IF stat = 1 THEN high 2 else low 2 endif GOTO loop outr4: if stat = 1 then high 3 else low 3 endif goto loop outr5: IF stat = 1 THEN high 4 else low 4 endif goto loop outr6: if stat = 1 then high 5 else low 5 endif goto loop outr7: if stat = 1 then high 6 else low 6 endif goto loop outr8: if stat = 1 then high 7 else low 7 endif goto loop outr9: if stat = 1 then porta.0 = 1 else porta.0 = 0 endif goto loop outr10: if stat = 1 then porta.1 = 1 else porta.1 = 0 endif goto loop outr11: if stat = 1 then porta.2 = 1 else porta.2 = 0 endif goto loop outr12: if stat = 1 then porta.3 = 1 else porta.3 = 0 endif goto loop end
Bookmarks