Use of the STM32 photoresistors sensor module

Source: Internet
Author: User

This experiment with 2.2 inch TFT LCD screen display, when the light is weak when the display "dim", Light intensity display "bright".

The experiment used is shown in the 3-wire photoresistors sensor module, use: Light intensity detection, light brightness sensor, intelligent trolley light-seeking module. Module features: Comparator output, signal clean, good waveform, strong driving ability, more than 15mA, with adjustable potentiometer to adjust the detection of light brightness, output form: Digital switching output (0 and 1), using a wide voltage LM393 comparator.

Module Instructions 1, the photosensitive resistor module is most sensitive to ambient light, generally used to detect the ambient light brightness, trigger a single-chip or relay module, etc. 2, the module in the ambient light brightness does not reach the set threshold, do output high level, when the external ambient light brightness exceeds the set threshold value, Do output low level, 3, do outputs can be directly connected with a single-chip microcomputer, through a single-chip microcomputer to detect high and low levels, thus to detect the ambient light brightness change;4, do output can directly drive the store relay module, which can be composed of a light-control switch .

Each pin function:

In this experiment, the do pin is connected to the PA0 foot and the power is connected to the 3.3V power supply.

 while(1){                if(Gpio_readinputdatabit (Gpioa, gpio_pin_0) = =0) {gui_drawfont_gbk24 ( -, the, Red,gray0,"Bright"); }Else{gui_drawfont_gbk24 ( -, the, Red,gray0,"Dark"); } Delay_ms ( -); Delay function 0.1S}

Among them: Gui_drawfont_gbk24 (70,80,red,gray0, "bright"), and Gui_drawfont_gbk24 (70,80,red,gray0, "gloom"); for the LCD display function, here is not the point. What I want to focus on here is the IF () judgment statement, which we pass through

if (Gpio_readinputdatabit (Gpioa, gpio_pin_0) = =0)

Statement to determine if the data pin is 0 (low), and if low, output the following statement,

Gpio_readinputdatabit (Gpioa, gpio_pin_0) = =0

For the STM32 read pin function, the PIN configuration is as follows:

=  gpio_pin_0;   //  Gpio_initstructure.gpio_mode == gpio_speed_50mhz;   &gpio_initstructure);  

The experimental results are as follows: (bright)

Cover the Sun with paper (dim)

[end] selected from: http://www.ciast.net/post/20151111.html

Use of the STM32 photoresistors sensor module

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.