Magnetic
The magnetic sensor can be used to detect when a magnet is close to the sensor.
MAGNETIC is the Magnetic Hall Effect sensor support module.
Add Input Device
Item |
Description |
---|---|
Magnetic |
Detects the presence of a magnetic field. The threshold value to determine the presence of the field is set through the trigger() function. The default value of the threshold is 150. |
CE products: from magnetic import *
TI-Nspire CX II: from ti_hub import *
|
|
|
The function to create the object is pasted from the menu.
var=magnetic("port")
Command: |
var=magnetic("port") |
---|---|
Command |
var=magnetic("port") |
Range: |
|
Describe: |
Create an object for the magnetic sensor attached to the “port”. |
Result: |
|
Type or |
Control |
var=magnetic_close()
Command: |
var=magnetic_close() |
---|---|
Command |
var=magnetic_close() |
Range: |
|
Describe: |
Returns a 0 or 1 if a magnet is detected close to the sensor. 0 = magnet detected 1 = no magnet detected The trigger value can be configured through the “var.trigger()” function. Default value of the trigger is 150 |
Result: |
|
Type or |
Control |
var.measurement()
Command: |
var.measurement() |
---|---|
Command |
var.measurement() |
Python |
TI Nspire CX II: from ti_hub import * m1 = magnetic("IN 1") mg = m1.measurement() print("Magnetic strength is: ", mg) mc = m1.magnet_close() if (mc == 0): print("Magnet detected") else print("No magnet detected") |
|
CE products: from magnetic import * m1 = magnetic("IN 1") mg = m1.measurement() print("Magnetic strength is: ", mg) mc = m1.magnet_close() if (mc == 0): print("Magnet detected") else print("No magnet detected") |
Range: |
Range: 0 – 16383 |
Describe: |
Returns a value representing the strength of the magnetic field near the sensor. |
Result: |
|
Type or |
Control |
var.trigger(level)
Command: |
var.trigger(level) |
---|---|
Command |
var.trigger(level) |
Range: |
The range for ‘level’ is 0 – 16383 The default value for level is 150 |
Describe: |
Use to set the trigger level for the “var.magnet_close()” function. |
Result: |
|
Type or |
Control |