Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 129 - 2629_Devagiri_C-8
P. 129

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

                      when started

                      set drive velocity to 100  %

                      set  count  to  1

                      repeat  3

                        drive  forward  for  800  mm

                       energize Magnet  to  boost
                        drive  reverse  for  800  mm

                       energize Magnet  to  drop

                        drive  forward  for  1200  mm

                       energize Magnet  to  boost

                        drive  reverse  for  1200  mm
                       energize Magnet  to  drop

                        drive  forward  for  1600  mm

                       energize Magnet  to  boost

                        drive  reverse  for  1600  mm

                       energize Magnet  to  drop
                        if  count  <     3    then

                         turn  right  for  90  degrees

                         drive  forward  for  800  mm

                         turn  left  for  90  degrees

                         change  count  by  1

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

                         The robot’s drive velocity is set to 100%, ensuring it moves quickly.
                         A variable called count is created and set to 1 at the start.
                         The robot then repeats the following sequence three times:

                        ● Stage Actions: The robot drives forward a set distance (800 mm, 1200 mm and 1600 mm),
                          activates its magnet to simulate picking up a disk, reverses the same distances and finally
                          deactivates the magnet to simulate dropping the disk.

                                                                                                                      127
                                                                                     VEXcode VR: Drive, Sense and Create

| 124 125 126 127 128 129 130 131 132 133 134 |