Data Sheet
Core Spartan Documentation Modern Robotics, Inc
Version 3.0.3 Page 37
8.6. Magnet Sensor (45-2020)
The Magnet Sensor can detect a magnetic field up to 4cm away. When the returned
value is increasing, the sensor is detecting the north pole of the magnet. If the value
returned is decreasing, then the sensor is detecting the south pole magnet. The sensor
value ranges from -340 to +340 where 0 indicates no magnetic field. Refer to the
Magnet Sensor example folder for more information on different implementation
methods.
Magnet Sensor functions:
CORE_ANALOG(unsigned char port)
int read(void)
CORE_ANALOG(unsigned char port)
Save the pinMode for future reads and writes.
This must be done before setup().
CORE_ANALOG mag(A2);
int read(void)
Returns the value read by the magnetic sensor.
int value;
value = mag.read();
…or…
Serial.print(mag.read());










