'>Hextor_0play.BSx '============================================================== '{$stamp BS2Sx} '============================================================== 'Now you have got the legs on, this program lets you have a 'little play with Hextor. 'The buttons allow you to go Forward, Backward, Right, Left '============================================================== BOStx con 0 'pin serial to BOS processor BOSrx con 1 'pin serial from BOS processor epower con 2 'pin high turns on power to electronics BOSbusy var in4 'pin BOS processor busy => high lcdtx con 6 'pin to send to LCD lcdrx con 7 'pin to receive from LCD Rled con 8 'pin high turns on right green led Lled con 9 'pin high turns on left red led i96n con 16624 '9600 baud, 8 bit, no parity, inverted poweruptime con 1500 'pause before powering up electronics BOScmnd var byte 'byte to send to BOS processor arg1 var byte 'command argument speednib var arg1.highnib servonib var arg1.lownib arg2 var byte 'command argument servo var nib 'servo number servospeed var nib lcdbtns var byte 'button state 'during downloading the power to the electronics is turned off, 'if it is turned back on again too soon the electronics, 'especially the ultrasonics do not power up properly, 'so wait poweruptime before turning power on. init: output Rled output Lled high Rled high Lled pause poweruptime high epower 'turn on electronics debug cls BOScmnd ="U" 'Stand gosub tellBOS pause 1000 'give time for lcd to get ready gosub lcdmsg1 start: gosub btns if lcdbtns.bit0=1 then Fd if lcdbtns.bit1=1 then Bk if lcdbtns.bit2=1 then Rt if lcdbtns.bit3=1 then Lt goto start Fd: BOScmnd ="F" gosub tellBOS goto start Bk: BOScmnd ="B" gosub tellBOS goto start Rt: BOScmnd ="R" gosub tellBOS goto start Lt: BOScmnd ="L" gosub tellBOS goto start '------------- subroutines --------------------- lcdmsg1:serout lcdtx,i96n,[16,64,"Playtime "] serout lcdtx,i96n,[16,80, " Fd Bk Rt Lt "] return '----------------------- btns: serout lcdtx,i96n,[27,"K0"] 'ask LCD for button status serin lcdrx,i96n,200,nolcd,[lcdbtns] 'get byte nolcd:return '-------------------- tellBOS: pause 10 'give the BOS time to go into receive mode if BOSbusy=1 then tellBOS 'wait until BOS not busy serout BOStx,i96n,[BOScmnd] return '------------------------ end program -------------------------