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 #130 background imageLoading...
Page #130 background image
Page 140
: seek
forward
0 1 TIMER_SET
BEGIN 2 sensorValue threshold @ 3 - < UNTIL
2 sleep
1 TIMER_GET returnTime !
stop
;
: return
forward
returnTime @ sleep
stop
;
: retrieve
seek
grab
turnAround
return
release
turnAround
;
: Minerva
initialize
calibrate
5 0 DO
retrieve
LOOP
;
The pbFORTH implementation of Minerva's program closely resembles the NQC version of the program presented in Chapter 5.
By the time all the simpler words are defined, the more complex words are simply combinations of the earlier ones. Keep this in mind—I'll describe the words in Minerva's program starting at the
end and returning to the beginning.
The main program word, Minerva, pretty much describes itself. It initializes the RCX, which includes configuring input 3 as a light sensor input. Then it calls calibrate to take an average
reading of the light sensor. Finally, it loops five times, calling retrieve to go pick up something and bring it back.
The retrieve word is also pretty self-explanatory. It calls seek to drive forward and look for an object to pick up. Then grab is called to grab the object. Minerva turns around and heads back
to her starting point with turnAround and return. Then she drops the object, with release, and turns around again with turnAround. With the simpler words defined correctly,
retrieve is a highly readable piece of programming:
: retrieve
seek

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