Skip to content

Your cart is empty

Have an account?

Log in to check out faster.

Sugar Modules - Sugar Potentiometer

Sugar Modules - Sugar Potentiometer

../../_images/poten1.png

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

Product Specifications:

  • Dimensions: 24 x 24 x 23 mm

  • Weight: 6.7g

  • Type: Analog

  • Degree of Movement: 270

Wiring

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

../../_images/poten_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

Sample Program

 

Kittenblock Programming Tutorial

../../_images/kbbanner.png

 

MicroPython Programming Tutorial

Rotation(pin)

value()

  • value(): Returns sensor value


Sample Program

from future import *

from sugar import *

rotation = Rotation('P1')

x = 0

# It's the interval mapping formula, you can just use it directly

def valmap(x, in_min, in_max, out_min, out_max):

    return int((x-in_min) * (out_max-out_min) / (in_max-in_min) + out_min)

neopix=NeoPixel("P7",3)

while True:

    x = (round(valmap(rotation.value(), 0, 4096, 0, 255)))

    neopix.setColorAll((x,x,x))

 

If you have any question, please feel free to contact us at Discord, we will always be there to help.

 

KittenBot Team

Leave a comment

Please note, comments need to be approved before they are published.

SUBHEADING

Blog posts