Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 194 - CodePilot V5.0 C8
P. 194

    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

                       192
                            CodePilot (V5.0)-VIII

| 189 190 191 192 193 194 195 196 197 198 199 |