Sugar Magnet Sensor Module

../../_images/magnet1.png

This is a magnet sensor module in the Sugar sensor series. The pin holes on the back allow compatibility with plastic building bricks.

Product Specifications

  • Dimension: 24 x 24 x 16 mm

  • Weight: 4.7g

  • Type: Digital

Wiring

Use a 3Pin cable to connect the module to Robotbit Edu.

../../_images/magnet_wire.png

Programming Tutorial

MakeCode Programming Tutorial

../../_images/mcbanner.png

Import Sugar Extension

Search for sugar in the search bar (Kittenbot products has been verified by Microsoft)

../../_images/sugar_search.png

Extension URL

Sugar extension: https://github.com/KittenBot/pxt-sugar

Importing Extensions

../../_images/magnet_mc_code.png

Sample Program

Kittenblock Programming Tutorial

../../_images/kbbanner.png

../../_images/magnet3.png

MicroPython Programming Tutorial

Hall(pin)
value()
  • value(): Returns sensor status

Sample Program

from future import *
from sugar import *

hall = Hall('P1')

while True:
    if hall.value():
        buzzer.tone(440, -1)
    else:
        buzzer.stop()