Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 125 - 2629_Devagiri_C-8
P. 125

    The explanation of the code is as follows:
                         The program starts when the when started block is triggered.

                         The robot turns right by 90°, moves forward 600 mm, turns left by 90° and moves forward
                        another 600 mm to reach the centre.
                         The pen is set to green and moved down to start drawing.

                         A repeat loop runs 6 times to draw each side of the hexagon. In each iteration, the robot drives
                        forward 400 mm and turns right by 60° to form the hexagon.

                      Program 4 Draw a star on the Grid Map playground.

                     The task is to make the robot draw a five-pointed star shape on the Grid Map playground using
                     the Drawing blocks.

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

                      when started

                       turn  right  for  90  degrees

                       drive  forward  for  400  mm

                       turn  left  for  90  degrees

                       drive  forward  for 1000  mm

                      move pen  down

                      set pen to width medium

                       repeat  5

                        drive  forward  for  1200  mm

                        turn  right  for  144  degrees

                      The explanation of the code is as follows:

                         The program starts when the when started block is triggered.
                         The robot turns right by 90°, moves forward 400 mm, turns left 90° and moves forward
                        1000 mm to position itself near the centre.

                         The pen is moved down and set to medium width.
                         The robot turns right by 90° to align for drawing the star.

                         A repeat loop runs 5 times to draw each side of the star:
                        •  The robot drives forward 1200 mm and turns right by 144° after each side to form the star.

                                                                                                                      123
                                                                                     VEXcode VR: Drive, Sense and Create

| 120 121 122 123 124 125 126 127 128 129 130 |