Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 126 - 2629_Devagiri_C-8
P. 126

    USING EYE SENSING BLOCKS

                      The Eye sensing blocks enable the robot to detect colours and objects using its Front or Down Eye
                      sensors. These blocks are located in the Sensing category under Sensing – Eye.
                      Some of the key blocks are as follows:

                                       Blocks                                         Description
                       Eye sensor near object?                  This block detects a specific object (like an object shape

                          FrontEye   is near object?            or a symbol) in the robot’s visual field.

                       Eye Sensor detects [color]?              This block detects a specific colour in the robot’s view.

                          FrontEye  detects  red  ?

                       Eye Sensor brightness in %               This block detects the brightness of the surface in front

                         FrontEye   brightness in %             of the robot.

                        Program 5 Make the robot move and respond according to the detected colour.

                      This program shows how a robot uses colour detection to make movement decisions. When it
                      detects green, it turns right 90°, blue makes it turn left 90° and red makes it stop. The code and
                      its output are shown below:

                        when started

                        set drive velocity to  40  %
                        set turn velocity to  40  %

                        drive  forward

                        forever

                          if   FrontEye  detects  green  ?  then
                           turn  right  for  90  degrees

                           drive  forward

                          if   FrontEye  detects  blue  ?  then
                           turn  left  for  90  degrees

                           drive  forward

                          if   FrontEye  detects  red  ?  then
                           stop driving

                       124
                            Premium Edition-VIII

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