'{$STAMP BS2} 'snippets.bs2 - Useful code snippets - Roger Arrick 2/22/03 'LED control. low 10 'Red LED on. high 10 'Red LED off. low 11 'Green LED on. high 11 'Green LED off. 'Reading whiskers. if in0=0 then wh1 'If left whisker is on then goto wh1. if in0=1 then wh1 'If left whisker is off then goto wh1. if in1=0 then wh1 'If right whisker is on then goto wh1. if in1=1 then wh1 'If right whisker is off then goto wh1. 'Reading jumpers. if in12=0 then wh1 'If Jumper J7 on then goto wh1. if in12=1 then wh1 'If Jumper J7 off then goto wh1. if in13=0 then wh1 'If Jumper J6 on then goto wh1. if in13=1 then wh1 'If Jumper J6 off then goto wh1. 'Reading pushbutton switches. if in14=0 then wh1 'If Button SW1 on then goto wh1. if in14=1 then wh1 'If Button SW1 off then goto wh1. if in15=0 then wh1 'If Button SW2 on then goto wh1. if in15=1 then wh1 'If Button SW2 off then goto wh1. 'speaker control. low 9 'Speaker off (conserve power). freqout 9,200,1500 'Beep the speaker (high pitch). low 9 freqout 9,200,400 'Beep the speaker (low pitch). low 9 'Speaker off. 'Steering motor control. 'These require a variable defined named charn serout 8,396,["!1R180"] 'Steer center. serin 8,396,[charn] 'Get response 'A' back. serout 8,396,["!1R1FF"] 'Steer left. serin 8,396,[charn] 'Get response 'A' back. serout 8,396,["!1R101"] 'Steer right. serin 8,396,[charn] 'Get response 'A' back. serout 8,396,["!1R100"] 'Relax steering motor. serin 8,396,[charn] 'Get response 'A' back. 'Drive motor control 'These require a variable defined named charn serout 8,396,["!1M1160028"] 'Drive forward 10". serin 8,396,[charn] 'Get response 'A' back. serout 8,396,["!1M1060028"] 'Drive reverse 10". serin 8,396,[charn] 'Get response 'A' back. serout 8,396,["!1M116FFFF"] 'Drive forward forever. serin 8,396,[charn] 'Get response 'A' back. serout 8,396,["!1M1100001"] 'Drive motor off. serin 8,396,[charn] 'Get response 'A' back. 'End of useful snippets.