Basic Stamp 2 Robot Programming - ISL
Basic Stamp 2 Robot Programming - ISL
Basic Stamp 2 Robot Programming - ISL
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
6-14 Chapter Six<br />
<strong>Robot</strong>Right con 8 ‘ Turn Right for 200 msecs<br />
<strong>Robot</strong>LEDOn con 9 ‘ Turn on the <strong>Robot</strong>’s LED<br />
<strong>Robot</strong>LEDOff con 10 ‘ Turn off the <strong>Robot</strong>’s LED<br />
<strong>Robot</strong>PWM0 con 11 ‘ PWM = 0% Duty Cycle<br />
<strong>Robot</strong>PWM1 con 12 ‘ PWM = 1st “Notch”<br />
<strong>Robot</strong>PWM2 con 13 ‘ PWM = 2nd “Notch”<br />
<strong>Robot</strong>PWM3 con 14 ‘ PWM = 3rd “Notch”<br />
<strong>Robot</strong>PWM4 con 15 ‘ PWM = 100% Duty Cycle<br />
<strong>Robot</strong>PWM con 16 ‘ Return the Current PWM Value<br />
<strong>Robot</strong>State con 17 ‘ Return the Executing State<br />
<strong>Robot</strong>Whiskers con 18<br />
‘ Return State of the “Whiskers”<br />
‘ Bit 0 - Left “Whisker”<br />
‘ Bit 1 - Right “Whisker”<br />
<strong>Robot</strong>CDSL con 19 ‘ Return Value of Left CDS Cell<br />
<strong>Robot</strong>CDSR con 20 ‘ Return Value of Right CDS Cell<br />
<strong>Robot</strong>Button con 21 ‘ Return Last Remote Button<br />
‘ Pressed<br />
‘ 0 - No Buttons Pressed<br />
‘ 1 - Leftmost Button Pressed<br />
‘ 2 - Middle Button Pressed<br />
‘ 3 - Rightmost Button Pressed<br />
‘ After “<strong>Robot</strong>Button” Operation,<br />
‘ Button Save in <strong>Robot</strong> is Cleared<br />
‘ <strong>Robot</strong> Interface Pins<br />
SC con 14<br />
SD con 15<br />
‘ <strong>Robot</strong> Interface Variables<br />
<strong>Robot</strong>Data var byte<br />
‘ Define the I/O Pins<br />
‘ Data Byte to Send to/Receive<br />
‘ from <strong>Robot</strong><br />
‘ <strong>Robot</strong> Operation Subroutines<br />
<strong>Robot</strong>Send<br />
‘ Send the Byte in “<strong>Robot</strong>Data”<br />
low SC<br />
‘ Hold Low for 1 msec before<br />
pause 1 ‘ Shifting in Data<br />
shiftout SD, SC, LSBFIRST, [<strong>Robot</strong>Data]<br />
high SC<br />
return<br />
<strong>Robot</strong>SendReceive<br />
‘ Send the Byte in “<strong>Robot</strong>Data”<br />
low SC<br />
‘ Hold Low for 1 msec before<br />
pause 1<br />
‘ Shifting in Data<br />
shiftout SD, SC, LSBFIRST, [<strong>Robot</strong>Data]<br />
pause 1<br />
‘ Wait for Operation to Complete<br />
shiftin SD, SC, LSBPOST, [<strong>Robot</strong>Data]<br />
high SC<br />
return<br />
Experiment 1—“Hello World!”<br />
Before starting to create BS2 applications for the TAB Electronics Build Your<br />
Own <strong>Robot</strong> Kit, I want to first show you how the BS2 is programmed and how you<br />
can use the PBASIC “debug” function to feed back information to you. This applica-