EasyManuals Logo
Home>LEGO>Toy>MINDSTORMS Robots

LEGO MINDSTORMS Robots User Manual

LEGO MINDSTORMS Robots
226 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #132 background imageLoading...
Page #132 background image
Page 142
Finally, as an added bonus, the average value is shown on the RCX's display:
threshold @ showValue
The average value, threshold, is used in the seek word to find a dark object to pick up. seek drives forward until the light sensor returns a reading that is 3 less than the average:
BEGIN 2 sensorValue threshold @ 3 - < UNTIL
Debugging
When you're writing your own programs, there are two things you should keep in mind when you are debugging:
1. The interactive nature of the pbFORTH interpreter can really help. You can, for example, make changes in a word by redefining it. With legOS (see Chapter 10), by contrast, you'd have to
compile and download a whole new version of your software. With pbFORTH, you can simply make new definitions for the words that aren't working.
Furthermore, you can interactively test every word in your program. This makes it easy to drill down from the higher layers to the lower layers of your program to identify problems. Any
word that is defined can be interactively tested. This is powerful medicine indeed.
2. On the other hand, you need to be very careful about endless loops. If you do get stuck executing an endless loop, there's no way to stop pbFORTH short of removing the batteries. In this case,
you will have to use your firmware download utility to reload pbFORTH.
If you entered all of the Minerva source code, you can interactively test any of its words. For example, to show a number on the display, do something like this:
RCX_INIT
ok
42 showValue
ok
To pause for half a second, you could do this:
5 sleep
ok
To test out the calibrate word, try this:
initialize
ok
Interestingly, new definitions don't replace the old ones, they just mask them out. If you want to return to an earlier definition, You should use the MARKER word. See the pbFORTH web site for details.

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the LEGO MINDSTORMS Robots and is the answer not in the manual?

LEGO MINDSTORMS Robots Specifications

General IconGeneral
BrandLEGO
ModelMINDSTORMS Robots
CategoryToy
LanguageEnglish

Related product manuals