Using the Electromagnet in VEXcode VR

This Electromagnet on the VEX VR Robot can be controlled to pick up and drop disks with metal cores.


What is an Electromagnet?

VEXcode VR Playground with the Electromagnet robot and both block-based and Python coding workspaces

An electromagnet is a specific type of magnet where the magnetic field is produced by an electric current. The VEX VR Robot has an electromagnet to pick up and put down disks that contain metal cores.

Electromagnet mounted on the VR robot’s front bumper

The VEX VR Robot Electromagnet is located at the front of the robot pointing down towards the Playground currently in use.


How Electromagnets Work

VEXcode VR Blocks

Electromagnet mounted on the front bumper of the VR robot

VEXcode VR Python

def main():
magnet.energize(BOOST)

On specific Playgrounds in VEXcode VR, there are disks with metal cores that can be used with the Electromagnet.

By setting the Electromagnet to 'boost,' the user is able to energize the magnet.

VR Robot uses the Electromagnet to pick up disks in the Disk Mover Playground

Any disks beneath the Electromagnet will be picked up by the VR Robot.

VEXcode VR Blocks

VEXcode VR robot uses an electromagnet to pick up a disk

VEXcode VR Python 

def main():
magnet.energize(DROP)

By setting the Electromagnet to 'drop,' the user de-energizes the magnet.

Electromagnet mounted on the VR Robot’s front bumper

Any disk currently being held by the VR Robot Electromagnet will be dropped.


Uses in VEXcode VR

VEXcode VR Blocks Disk Transport Playground
Electromagnet mounted on the front bumper of the VEXcode VR robot VEXcode VR Playground with the Electromagnet robot selected in the robot menu
VEXcode VR Python
def main():
drivetrain.drive_for(FORWARD, 700, MM)
drivetrain.turn_for(LEFT, 90, DEGREES)
magnet.energize(BOOST)
drivetrain.drive_for(FORWARD, 300, MM)
wait(2, SECONDS)
magnet.energize(DROP)

The VEXcode VR Robot Electromagnet can be used on the Disk Transport Playground. Disks of varying colors lie within a walled area. The following example has the VR Robot drive forward into the Castle walls, turn left, then pick up and drop a blue disk.

VEXcode VR robot showing the electromagnet location and labeled components

For an extra challenge, attempt to stack disks on top of one another. While the Electromagnet can only hold one disk at a time, the user is able to stack disks two high and still travel over the stack.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: