Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to measure light intensity with LED on PYB Nano

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces how to use LED to measure light intensity on PYB Nano, the content is very detailed, interested friends can refer to, hope to be helpful to you.

A long time ago, TI did a demo when promoting MSP430, measuring ambient light intensity with ordinary LED. Let's also try it on PYB Nano.

The principle of using LED to measure light intensity is that LED is also a diode, the junction capacitance of its PN junction will be affected by light intensity, and there is a certain corresponding relationship between discharge or charging speed and light intensity. Charge / discharge the LED first, delay a few milliseconds and then measure the voltage on the LED. The voltage will change obviously under different light intensity.

To achieve this function, the control GPIO of LED is required with the function of ADC. On PYB Nano, LED uses PA0-PA3, and they all support ADC and can all be tested. The following program demonstrates this function. After entering the program, use test ('A0') to test the first LED,test (' A1') to test the second.

From pyb import Pin, ADCdef test (pin='A0', count=100): pn = Pin (pin, Pin.OUT) for i in range (count): tmp = 0 pn (1) pn = Pin (pin, Pin.IN) Pull=Pin.PULL_NONE) pyb.delay (1) adc = ADC (Pin (pin)) for N1 in range (8): tmp + = adc.read () print (tmp) pn = Pin (pin, Pin.OUT) pn (0) pyb.delay

When 4 LED were tested respectively, the red LED had the worst effect and changed little, while the other LED changed significantly, which indicated that the running effect had a lot to do with LED. Although it can not be used to accurately measure light intensity, it is possible to measure simple ambient light intensity while making indicator lights, such as adjusting LCD backlight, changing LED brightness and so on.

Here are the effects of LED2/LED3 (green and yellow):

On how to use LED light intensity measurement on PYB Nano to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report