Skip to main content

Lesson 3: Using Sensors and the Electromagnet to Pick up a Disk

Using the Down Eye Sensor with the Electromagnet

This Lesson will use reported sensor feedback to solve the same challenge as Lesson 2. The VR Robot will pick up and move the first blue disk into the blue goal.

  • Start a new project and select the Disk Mover Playground when prompted. Image of the Disk Mover Playground selection tile
  • Name the project Unit8Lesson3.Unit8Lesson3

     

  • Add four comments to the project. Add comments for each of the steps necessary for the VR Robot to drive to the first disk, pick it up, and return it to the blue goal.
    image of comments to describe the project plan
  • Drag or type a while loop with a not condition into the workspace beneath the first comment.
    image of the project with a while loop with a not condition added beneath the first comment
  • The down_eye.near_object command reports True when the Down Eye Sensor on the VR Robot detects a colored disk on the Disk Mover Playground. The disks are on the floor of the Playground and cannot be detected by the Front Eye Sensor, therefore the Down Eye Sensor will detect the disks. Drag or type the down_eye.near_object command as the condition of the while loop.
    image of the down eye near object command as the condition of the while loop
  • The commands inside the while loop will run when the VR Robot does NOT detect an object. To reach one of the disks, the VR Robot will need to drive forward until the disk is detected.
    FIXED_Disk Mover Start Position_Black_Pen
  • Drag or type a drive command inside the while loop.
    image of the drivetrain command in the while loop
  • When a disk is detected, the VR Robot will need to stop driving in order to pick it up. Drag or type a stop command outside the while loop. image of the stop command outside the while loop
  • Notice that the drive and wait commands are indented under the while loop header, meaning the commands are inside the loop. The gray line can also help indicate which commands are properly indented and inside a loop. The stop command is in line with the loop header, meaning the stop command is outside the loop. Ensure the commands are correctly indented, or the project may not run as expected. 
  • Now, instruct the VR Robot to pick up the disk with the Electromagnet by dragging or typing an energize command after the second comment.
    image of the energize command beneath the second comment
  • Open the Playground Window if it is not already open. Be sure the Disk Mover Playground opens, and run the project.
  • The VR Robot drives forward until the first blue disk is detected by the Down Eye Sensor, stops driving, and energizes the Electromagnet to pick up the disk.
    u8_Lesson3_FirstPuck_0

Project Flow to Pick up the First Disk

Notice how the while loop with a not condition uses sensor feedback to successfully pick up the first disk:

  • The VR Robot drives forward while the Down Eye Sensor does not detect an object.

  • Once the Down Eye Sensor on the VR Robot detects an object, the project moves to the next command outside the while loop and stops driving.

  • The project continues, so the VR Robot energizes the Electromagnet to pick up the disk.
image of the project flow to pick up the first disk

Select the Next button to continue with the rest of this Lesson.