Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use locator to control LED brightness in PYB Nano

Shulou Source: shulou.com Published: 2022-06-01 04:53:27 09月30日 Update

This article will explain in detail how to use the positioner to control the LED brightness in PYB Nano. The quality of the article is high, so Xiaobian shares it with you as a reference. I hope you have a certain understanding of relevant knowledge after reading this article.

The Demo below demonstrates using a positioner to control LED brightness.

Use an external positioner and connect the positioner to PYB Nano pin X9/PB1 with a Dupont cable.

Then type in the following program

>>> from pyb import ADC, Pin >>> adc = ADC(Pin('X9')) >>> while True: ... dat = adc.read() ... pyb.LED(1).intensity(dat>>4) ... print(dat) ... pyb.delay(200)

Changing the positioner will output the current ADC result on the screen and change the brightness of LED1.

Note:

X9 above can be changed to X0-X9 (ADC function supported).

LED(1) can be changed to 1-4, they all support brightness adjustment function.

About PYB Nano how to use the positioner to control LED brightness to share here, I hope the above content can have some help for everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

Tags: Locator positioning brightness control face content function article more knowledge article support good at the same time screen program result quality and will DuPont Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Huawei Redmi OPPO Reno macOS