# Magnetic Sensor

![../../\_images/magnet2.png](https://kittenbothk-eng.readthedocs.io/en/latest/_images/magnet2.png)

This sensor can detect magnetic field, it returns a digital value,

Returns 0 when a magnetic field is detected, otherwise returns 1.

### Specifications[](https://kittenbothk-eng.readthedocs.io/en/latest/functional_module/outdated/magnetic.html#specifications)

* Voltage: 3.3V\~5V
* Type: Digital Module
* Interface: 3Pin PH2.0

### Wiring Diagram[](https://kittenbothk-eng.readthedocs.io/en/latest/functional_module/outdated/magnetic.html#wiring-diagram)

#### Robotbit Shield[](https://kittenbothk-eng.readthedocs.io/en/latest/functional_module/outdated/magnetic.html#robotbit-shield)

Connect the sensor to Robotbit Shield’s 3Pin port.

![../../\_images/magnet\_wire2.png](https://kittenbothk-eng.readthedocs.io/en/latest/_images/magnet_wire2.png)

#### Robotbit[](https://kittenbothk-eng.readthedocs.io/en/latest/functional_module/outdated/magnetic.html#robotbit)

Connect the sensor to Robotbit’s pin and 3V pin.

![../../\_images/magnet\_wire1.png](https://kittenbothk-eng.readthedocs.io/en/latest/_images/magnet_wire1.png)

### MakeCode Coding Tutorial[](https://kittenbothk-eng.readthedocs.io/en/latest/functional_module/outdated/magnetic.html#makecode-coding-tutorial)

![../../\_images/mcbanner.png](https://kittenbothk-eng.readthedocs.io/en/latest/_images/mcbanner.png)

![../../\_images/acbanner.png](https://kittenbothk-eng.readthedocs.io/en/latest/_images/acbanner.png)

#### This module can be used with Microbit and Meowbit.[](https://kittenbothk-eng.readthedocs.io/en/latest/functional_module/outdated/magnetic.html#this-module-can-be-used-with-microbit-and-meowbit)

**Reading the sensor value**[****](https://kittenbothk-eng.readthedocs.io/en/latest/functional_module/outdated/magnetic.html#reading-the-sensor-value)

#### Microbit:[](https://kittenbothk-eng.readthedocs.io/en/latest/functional_module/outdated/magnetic.html#microbit)

![../../\_images/digitRead\_code.png](https://kittenbothk-eng.readthedocs.io/en/latest/_images/digitRead_code.png)

#### Meowbit:[](https://kittenbothk-eng.readthedocs.io/en/latest/functional_module/outdated/magnetic.html#meowbit)

![../../\_images/digitRead\_codeMeow.png](https://kittenbothk-eng.readthedocs.io/en/latest/_images/digitRead_codeMeow.png)

### KittenBlock Coding Tutorial[](https://kittenbothk-eng.readthedocs.io/en/latest/functional_module/outdated/magnetic.html#kittenblock-coding-tutorial)

![../../\_images/kbbanner.png](https://kittenbothk-eng.readthedocs.io/en/latest/_images/kbbanner.png)

#### Load Robotbit Extension[](https://kittenbothk-eng.readthedocs.io/en/latest/functional_module/outdated/magnetic.html#load-robotbit-extension)

![../../\_images/addRB.png](https://kittenbothk-eng.readthedocs.io/en/latest/_images/addRB.png)

**Reading the sensor value**[****](https://kittenbothk-eng.readthedocs.io/en/latest/functional_module/outdated/magnetic.html#id1)

![../../\_images/magnet\_codekb.png](https://kittenbothk-eng.readthedocs.io/en/latest/_images/magnet_codekb.png)

### Mu Editor Coing Tutorial[](https://kittenbothk-eng.readthedocs.io/en/latest/functional_module/outdated/magnetic.html#mu-editor-coing-tutorial)

#### Reading the sensor value[](https://kittenbothk-eng.readthedocs.io/en/latest/functional_module/outdated/magnetic.html#id2)

![../../\_images/magnet\_codemu.png](https://kittenbothk-eng.readthedocs.io/en/latest/_images/magnet_codemu.png)
