Page 199 - The Unofficial Guide to Lego Mindstorms Robots
P. 199

188


              sub initialize() {
                  SetSensor(BUMP_SENSOR, SENSOR_TOUCH);
                  SetSensor(LIGHT_SENSOR, SENSOR_LIGHT);
                  ClearMessage();
                  score = 0;
                  Fwd(OUT_B);
                  SelectDisplay(5);
                  calibrateLightSensor();
              }

              #define NUMBER_OF_SAMPLES 10
              int i;
              int  runningTotal;

              void calibrateLightSensor() {
                  // Take an average light reading.
                  i = 0;
                  runningTotal = 0;
                  while (i   < NUMBER_OF_SAMPLES) {
                      runn ingTotal += LIGHT_SENSOR;
                      Wait(10);
                      i += 1;
                  }
                  averageLight = runningTotal / NUMBER_OF_SAMPLES;
              }

          Online Resources

          mattdm's Mindstorms stuff
          http://www.mattdm.org/mindstorms/
          This is the original RoboTag web page, created by Matthew Miller. It contains the original source code and a couple of movies
          of RoboTag in action.

          Brooks' Subsumption Architecture
          http://ai.eecs.umich.edu/cogarch3/Brooks/Brooks.html
          This page has some background on subsumption architecture. If you really want to learn more, however, you should look up
          Brooks' papers; they're an excellent read.
   194   195   196   197   198   199   200   201   202   203   204