mixly temperature sensor, sound and light sensor

 Table of contents

Temperature Sensor

Alarm when the temperature reaches a certain degree

sound, light sensor

Smart Corridor Light 


Temperature Sensor

Used to obtain the actual temperature value (°C)

Alarm when the temperature reaches a certain degree

 When the temperature of the warehouse reaches a certain degree, a red light will be on and an alarm will be issued.

 

sound, light sensor

Smart Corridor Light 

Function 1. Judging light and sound; 2. When the light is dark and there is sound, the light will automatically turn on.

step

Drag out the "Print (wrap)" module from the "Serial Port" directory, and copy it once, and then drag out the "Get the value of the light sensor" and "Get the value of the sound sensor" from the "Onboard Sensor" directory. A module, connected to the serial port printing, so that we can see the value of the sensor in the serial monitor after uploading, and write the following program based on these values.

Judge the surrounding light level and sound level. Drag out the "...=..." module from the "Logic" module category and adjust it to "...<..."; add "Get the value of the light sensor" on the left; drag the "0" module from the "Mathematics" module category on the right, and adjust It is "xxx"; set the sound judgment conditions in the same steps.

Controls that both conditions are met simultaneously. Drag the "...and..." module from the "Logic" module category, and place the light and sound control conditions on the left and right sides.

Turn on the RGB lights. Drag out the "RGB light" module, adjust the value to a certain value, use the "delay" module to make the RGB light on for 5 seconds, and then adjust the value of the RGB light to "0,0,0" to turn off the light. (Don't forget to set the RGB light mode) 

Combine the judgment conditions and the part of the code that lights up the RGB lights with the "if...execute..." module.

Finally, add a short delay at the bottom of the program, and add a "when the condition is true...repeat..." module on the outermost side to let the program execute cyclically. 

 

Guess you like

Origin blog.csdn.net/weixin_72634509/article/details/130424126