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