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

26


          His basic program works something like this:

                 go forward
                 if I've bumped into something
                        back up
                        turn away from the obstacle
                        start over

          T his program translates pretty simply into the RIS programming environment, as shown in Figure 2-6. The program assumes
          that the two m otors are attached to outputs A and C, while the touch sensors should be attached to inputs 1 and 3.
































                                                        Figure 2-6.
                                                      Hank's program

          To create this program, enter the RIS software. Choose Program RCX from the main menu, then RCX Code. Use the menus
          on the left side of the screen to click and drag out different program ''blocks." If you're not familiar with this process, you
          should probably go back and take a look at LEGO's official documentation, either the printed material or the computer-based
          tutorial.

          Once you have created the program, download it and run it. (You can download or save a program by right-clicking on the
          main program block.) If everything goes right. Hank should amble around on your floor, trying to avoid things he bumps into.
          If you have pets, this would be a good time to introduce them to your new toy.
   32   33   34   35   36   37   38   39   40   41   42