Skip to main content

Lesson 3: Using Sensors with the Electromagnet

In the previous Lesson, you used the energize command and Drivetrain commands to pick up and move disks on the Disk Mover Playground with the VR Robot. This Lesson will solve the same challenge using reported sensor feedback and while loops.

A front view of the VR Robot in the blue goal on the Playground with the blue disk below the electromagnet, having been released in the goal.

Learning Outcomes

  • Identify that the down_eye.near_object command reports if the Down Eye Sensor is close enough to an object to detect a color.
  • Identify that the turn_to_heading command turns a drivetrain to a specific heading, using the Gyro Sensor.
  • Identify that the turn_to_heading command will determine which direction to turn based on the current heading of the Gyro Sensor.
  • Explain why a turn_to_heading command would be used instead of a turn or a turn_for command.
  • Describe the flow of a project that uses a while loop with a not condition with the Electromagnet to pick up and move a disk.

Why Use Sensors to Solve the Disk Mover Problem?

In Lesson 2, the VR Robot drove a specified distance using the drive_for command to pick up and move a blue disk back to the goal. The distance between the VR Robot and the first blue disk was estimated and checked using the dimensions of grid squares on the Disk Mover Playground. While this did solve the challenge, there is much room for error in duplicating the process to pick up multiple disks at various distances, which is necessary to solve the Disk Mover Challenge at the end of this Unit. Using reported sensor feedback is a more efficient way to solve this challenge, while also optimizing the project by using fewer commands.

What if the VR Robot collides with a disk and is knocked off course? What if the disks are in slightly different locations from the goal? Feedback from sensors can be used to precisely pick up and move disks without knowing their exact location on the Disk Mover Playground.

The steps to solve the challenge can be used to help determine which sensors to use in the project.

  • First: The VR Robot will drive to the first disk.

    A top down view of the Disk Mover Playground at the start, with the VR Robot in the center of the blue goal in the lower left corner. A dotted arrow points from the front of the robot to the first blue disk in front of it, illustrating the intended movement of the robot.
    • The disks are on the ground of the Playground. To determine where a disk is located, the Down Eye Sensor can be used with the down_eye.near_object command. Notice the position of the Down Eye Sensor in relation to the Electromagnet on the VR Robot. 

      The underside of the VR Robot showing the Down Eye Sensor located in the front center of the robot, directly behind the Electromagnet.
  • Second: The VR Robot will use the Electromagnet to pick up the first disk.

    A side view of the VR Robot on the Playground at the first blue disk location, with the Disk attached to the Electromagnet.
  • Third: The VR Robot will drive back to the goal.

    A top down view of the Disk Mover Playground with the VR Robot at the first blue disk, and a dotted arrow pointing from the rear of the robot back to the blue goal, illustrating the intended movement of the robot.
    • While driving back to the goal, the VR Robot can use the Distance Sensor to determine when to stop driving. The Distance Sensor can be used to determine how far away the front of the VR Robot is from the wall of the Playground. Using the get_distance command, the Distance Sensor can drive and stop when it is a specified distance from the wall, positioning the VR Robot in the goal space.

      A front view of the VR Robot with the Front Distance Sensor highlighted in the front center of the robot, directly above the Electromagnet.
  • Finally: The VR Robot will use the Electromagnet to drop the disk into the goal.

    A side view of the VR Robot in the blue goal, facing the back wall of the Playground, having dropped the blue disk in the goal.

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