> For the complete documentation index, see [llms.txt](https://sharinghub-eng.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-eng.kittenbot.hk/functional_module/sugar/potentiometer.md).

# Sugar Potentiometer Module

![](https://kittenbothk-eng.readthedocs.io/en/latest/_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.

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

### Programming Tutorial

### MakeCode Programming Tutorial

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

#### Import Sugar Extension

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

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

#### Extension URL

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

[Importing Extensions Tutorial](/programming-platforms/makecode-tutorial/kittenbot-and-makecode.md)

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

[Sample Program](https://makecode.microbit.org/_ACjLxwW4W3AW)

#### Kittenblock Programming Tutorial

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

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

#### MicroPython Programming Tutorial

```
Rotation(pin)
value()
```

* value(): Returns sensor value

Sample Program

```
from future import *
from sugar import *

rotation = Rotation('P1')

x = 0

# 区间映射公式，不需要了解太详细，直接套用就可以了
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))
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sharinghub-eng.kittenbot.hk/functional_module/sugar/potentiometer.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
