27.10.2014 Views

Basic Stamp 2 Robot Programming - ISL

Basic Stamp 2 Robot Programming - ISL

Basic Stamp 2 Robot Programming - ISL

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Basic</strong> <strong>Stamp</strong> 2 <strong>Robot</strong> <strong>Programming</strong> 6-15<br />

tion is a very traditional one for first-time programmers or people working with a<br />

new programming language or development system. Its purpose is to demonstrate<br />

that the programmer can implement a simple application.<br />

While you can find this application in the<br />

C:\tabrobotkit\code<br />

subdirectory, I would like to walk you through the process of creating the application<br />

on your own. I will not repeat these detailed instructions for creating an application<br />

in the later experiments, but this should act as a guide for you in creating your own<br />

applications.<br />

First, the robot should have the BS2 installed (with Pin 1 pointing toward the<br />

rear as I have discussed above), be connected to the PC, and placed on a nonconducting<br />

stand (with the wheels free to turn) as I’ve shown in Figure 6-9.<br />

With this done, turn on the robot. The LED on the robot will go on for a half second<br />

and the wheels will start to turn. Press the “Stop” button on the remote control,<br />

and leave the robot turned on. The robot is now waiting for a command from either<br />

the remote control or the BS2. As I have indicated elsewhere, the robot’s battery<br />

will power both the robot and the BS2 for a long period of time—you do not have to<br />

feel as though you are going to have to “rush” through the process of programming<br />

the robot.<br />

With the robot connected to the PC, you can now start up “stampw.” This application<br />

can be invoked from either<br />

C:\tabrobotkit\Hello World<br />

or from the desktop (after copying the icon to the desktop as I showed in the software<br />

installation instructions).<br />

“<strong>Stamp</strong>w” will come up with the blank dialog box shown in Figure 6-10. Next,<br />

“open” the “template.bs2” file in<br />

C:\tabrobotkit\Template<br />

by either clicking on “File” and then “Open” or by simply pressing the “Ctrl” and “O”<br />

keys together. In either case, the “Open” dialog box shown in Figure 6-11 will come<br />

up. Click on “template” to highlight it and then click on the “Open” button. This will<br />

load the “template.bs2” file into the stampw editor.<br />

Before you change the file, you should rename it. This is done by clicking on<br />

“File” and then “Save As” (as shown in Figure 6-12). When you have done this, you<br />

will get the dialog box shown in Figure 6-13. For this example, I changed the subdirectory<br />

so that the changed file was saved in to<br />

C:\tabrobotkit\Hello World<br />

and I saved the file as “My Hello World.” Now, the “stampw” dialog box that you are<br />

working with should look like Figure 6-14. Where I have put in a comment (this is the<br />

single quote, ‘—everything to the right of this is ignored) and four “pound signs”<br />

(####), replace this with the text<br />

debug “Hello World!”, cr<br />

end<br />

‘ Output Debug Message<br />

‘ Nothing more to do<br />

This can be done by deleting the four pound sign line and simply putting in the two<br />

new lines of text. The “stampw” dialog box should look like Figure 6-15.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!