Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 120 - 2629_Devagiri_C-8
P. 120

    Now,  observe how  the robot  behaves in the
                      playground.

                                     SHORT SIGN

                                   To open playground:
                                          Ctrl + I

                        Program 1    Move the robot on the Grid Map playground in zig-zag pattern.

                      The task is to make the robot move in a zig-zag pattern. This is achieved by having the robot
                      move forward and then alternate between turning right and left at a specific angle, creating a
                      back-and-forth movement.

                      The code and output of the given task are as follows:

                       when started

                       turn  right  for  60  degrees

                       drive  forward  for  200  mm
                       turn  left  for  60  degrees

                       drive  forward  for  200  mm

                       turn  right  for  60  degrees
                       drive  forward  for  200  mm

                       turn  left  for  60  degrees

                       drive  forward  for  200  mm
                       turn  right  for  60  degrees

                       drive  forward  for  200  mm

                       turn  left  for  60  degrees
                       drive  forward  for  200  mm

                       turn  right  for  60  degrees

                       drive  forward  for  200  mm
                       turn  left  for  60  degrees

                       drive  forward  for  200  mm

                      The robot will move along the dotted path that is not visible on the playground window.

                       118
                            Premium Edition-VIII

| 115 116 117 118 119 120 121 122 123 124 125 |