Magnet#

Energize Electromagnet#

The Energize Electromagnet block is used to set the VEX Robot Electromagnet to two different actions: boost or drop.

  energize [Magnet v] to [boost v]

Select which mode for the Electromagnet to use:

  • boost - turns on the electromagnet for as long as the duration was set using the Set Electromagnet Duration block.

  • drop - releases any object the electromagnet is holding.

Diagram illustrating the VEX Robot Electromagnet's boost and drop modes with power and duration settings.

In this example, the robot will set its electromagnet power to 75% and its duration to short (250 milliseconds) before turning on. After 250 ms, the electromagnet will automatically turn off.

  when started :: hat events
  [Set Electromagnet power to 75%.]
  set [Magnet1 v] power to (75) %
  [Set the electromagnet duration to 250ms.]
  set [Magnet1 v] duration to [short v]
  [Energize the electromagnet and wait until it automatically turns off.]
  energize [Magnet1 v] to [boost v]
  wait (0.25) seconds

Set Electromagnet Power#

The Set Electromagnet Power block is used to set the Electromagnet power that will be used when picking up an object with the Energize Electromagnet block.

  set [Magnet1 v] power to (50) %

You can use the Set Electromagnet Power block to adjust the strength of the electromagnet when picking up objects of varying weights. The block allows you to set the power level between 0% and 100%, giving you control over the electromagnet’s lifting capacity.

In this example, the robot will set its electromagnet power to 75% and its duration to short (250 milliseconds) before turning on. After 250 ms, the electromagnet will automatically turn off.

  when started :: hat events
  [Set Electromagnet power to 75%.]
  set [Magnet1 v] power to (75) %
  [Set the electromagnet duration to 250 ms.]
  set [Magnet1 v] duration to [short v]
  [Energize the electromagnet and wait until it automatically turns off.]
  energize [Magnet1 v] to [boost v]
  wait (0.25) seconds

Set Electromagnet Duration#

The Set Electromagnet Duration block is used to set how long the Electromagnet is turned on for.

  set [Magnet1 v] duration to [short v]

Select which duration for the Electromagnet to use when it is powered on for a boost. If this block is not used, the default duration is medium or 500 milliseconds.

  • short - 250 milliseconds

  • medium - 500 milliseconds

  • long - 1000 milliseconds

Image showing settings for VEX Robot Electromagnet power and duration options for boost and drop actions.

In this example, the robot will set its electromagnet power to 75% and its duration to short (250 milliseconds) before turning on. After 250 ms, the electromagnet will automatically turn off.

  when started :: hat events
  [Set Electromagnet power to 75%.]
  set [Magnet1 v] power to (75) %
  [Set the electromagnet duration to 250 ms.]
  set [Magnet1 v] duration to [short v]
  [Energize the electromagnet and wait until it automatically turns off.]
  energize [Magnet1 v] to [boost v]
  wait (0.25) seconds