For the complete documentation index, see llms.txt. This page is also available as Markdown.

Examples

Use-Case

This example program shows how to use a digital pushbutton / magnetic hall effect switch in an FTC OpMode. It initializes a DigitalChannel from the robot’s hardware map, configures it as an input, and continuously reads the switch state while the OpMode is active. The code reports whether the magnet is detected and implements basic software debouncing and edge detection so quick detections are captured reliably. These values are updated in real time and displayed on the Driver Station, giving teams immediate feedback as the magnet is withing range and not.

This example is especially useful for testing wiring and verifying the logic level of the input (“active-low,” so pressed = LOW). Teams can use it to prototype user inputs, limit switches on mechanisms, homing routines, and safety interlocks, or to trigger steps in autonomous sequences with a simple button press. Because the program focuses on direct digital input reading and telemetry, it doubles as a diagnostic/learning tool and requires no advanced programming knowledge—just a button wired to a digital port on the Control/Expansion Hub.

Detection Optimization

There are 3 hall-effect sensors connected in parallel. If one sensor detects a magnet, the device outputs active LOW. The 3 hall-effect sensors are laid out in the case as shown:

Ideal Magnet Z Distance:

0.5"

Ideal Magnet X Distance:

0.5"

Code Example

You must first install the AndyMark vendor libraries. Instructions can be found here

View Device API for a comprehensive list of commands

Last updated

Was this helpful?