> For the complete documentation index, see [llms.txt](https://sharinghub.kittenbot.hk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sharinghub.kittenbot.hk/functional_modules/outdated/magnetic.md).

# 磁場感應器模組

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

這是一隻可以感應磁場的模組，它返回的數值是數位形式。

數值範圍由0-1，沒有探測到磁石時返回1，探測到磁石時返回0。

### 產品參數

* 工作電壓：3.3V\~5V
* 類型：數位模組
* 接口：3Pin防反插

### 接線教學

#### Robotbit Shield

將磁場感應器模組連接到Robotbit Shield的3PIN接口。

![](https://kittenbothk.readthedocs.io/en/latest/_images/magnet_wire2.png)

#### Robotbit

將磁場感應器模組連接到Robotbit的針線和3V接口。

![](https://kittenbothk.readthedocs.io/en/latest/_images/magnet_wire1.png)

### MakeCode編程教學

![](https://kittenbothk.readthedocs.io/en/latest/_images/mcbanner14.png)

![](https://kittenbothk.readthedocs.io/en/latest/_images/acbanner1.png)

#### 此模組可供Microbit和Meowbit使用。

**讀取磁場數值編程**

#### Microbit:

![](https://kittenbothk.readthedocs.io/en/latest/_images/digitRead_code.png)

#### Meowbit:

![](https://kittenbothk.readthedocs.io/en/latest/_images/digitRead_codeMeow.png)

### KittenBlock編程教學

![](https://kittenbothk.readthedocs.io/en/latest/_images/kbbanner8.png)

#### 加載Robotbit插件

![](https://kittenbothk.readthedocs.io/en/latest/_images/addRB2.png)

**讀取磁場數值編程**

![](https://kittenbothk.readthedocs.io/en/latest/_images/magnet_codekb.png)

### Mu Editor編程教學

#### 讀取磁場數值編程

![](https://kittenbothk.readthedocs.io/en/latest/_images/magnet_codemu.png)
