Skip to main content

Lesson 2: Using the Electromagnet

  • Once the VR Robot reaches the first blue disk, the VR Robot must boost the Electromagnet using the [Energize Electromagnet] block. Drag the [Energize Electromagnet] block beneath the second comment.

    The same VEXcode VR project, with an Energize Electromagnet block added beneath the second comment. The project now reads When started, Drive to the first blue disk - drive forward for 750mm; then pick up the first blue disk - energize magnet to boost. Then the remaining two comments to complete the task.

For Your Information

The [Energize Electromagnet] block has two different modes: ‘boost’ and ‘drop.’  ‘Boost’ turns on the Electromagnet and creates the electromagnetic field needed to attract a disk to the Electromagnet.

The VEXcode VR Energize Electromagnet block with the parameter dropdown showing the options of boost and drop. The block reads energize magnet to boost.

‘Drop’ reverses the current of the Electromagnet and releases any disks being held by the Electromagnet.

The VEXcode VR Energize Electromagnet block with the parameter dropdown showing the options of boost and drop. The block reads energize magnet to drop.

Using Switch Blocks 

This is the Switch [Energize electromagnet] block. 

The Energize electromagnet Switch block with the Python command that reads magnet dot energize (BOOST). The Boost parameter is capitalized and in parentheses.

You can change the parameter of the Switch [Energize electromagnet] block by replacing "BOOST" with the word "DROP" in the parentheses. Be sure to use all capital letters when changing the parameter. 

Energize electromagnet Switch block to demonstrate the auto-complete feature. The block reads 'magnet dot energize (DROP)', and the user is typing in the Drop parameter using auto-complete.

  • Next, the VR Robot will drive in reverse back to the starting point with the blue disk. Place a [Drive for] block beneath the third comment. Set the [Drive for] block parameters to reverse 750 millimeters (mm).

    The same VEXcode VR project from before, with a Drive for block added beneath the third comment. The project now reads When started, drive to the first blue disk - drive forward for 750mm, then pick up the first blue disk - energize magnet to boost. Next a comment reads Drive in reverse to the blue goal, with a block reading Drive reverse for 750mm next. Lastly, the fourth comment reads drop the blue disk in the blue goal.

  • Once inside the blue goal, the VR Robot will need to release the blue disk. Add a [Energize Electromagnet] block beneath the fourth comment, and set to ‘drop.’

    The same VEXcode VR project to pick up and drop the first blue disk in the blue goal, with an Energize electromagnet block added beneath the final comment at the bottom of the stack. The parameter of the final Energize Electromagnet block is set to drop, so that the magnet will release the Disk in the blue goal as intended.

  • Open the Disk Mover Playground if it is not already open and run the project.

    A top down view of the Disk Mover Playground with the robot in the blue goal starting position and the first blue disk highlighted in a red box, four grid squares in front of it.

  • The VR Robot picks up the first blue disk by energizing the Electromagnet, then drives in reverse back to the blue goal and drops the blue disk.

    VR Robot in the corner of the Disk Mover Playground with the blue disk laying on the Playground beneath the Electromagnet.

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