Data Sheet

18
Demo code:
while (1) do
b=adc.read(0) --Analog read A0
if (b<100) then
gpio.write(1,gpio.HIGH)
else
gpio.write(1,gpio.LOW)
end
end
Under the environment of light, blocking light sensor , led will turn on. No block ,led turn off.
Lesson6: Raining detect
In our daily life, we play computer game or watch TV all-possessed indoor,sometime raining,
our clothes usually be wetted in the outdoor, but if there is a sensor that it can remind us that
when it begin to rain outside, tragedy will not happen to us. In this lesson, we will tell you how to
build it. When raining outside, the LED inside will be lighted.
Material:
Crowtail- ESP8266 NodeMCU x 1
Crowtail- LED x 1
Crowtail- Water sensor x 1
Hardware Connection
Open the LuaLoader, click the “Upload File…”choo se ESP8 266 NodeM CU kit demo
code -> P06_Rainning_detect -> init.lua. After the upload completed then click Download to
download the init.lua file.
Demo code:
a=gpio.read(2) --Digital read port 2
if (a==1) then
gpio.write(1,gpio.HIGH)
if (a==0) then
gpio.write(1,gpio.LOW)
end
end
When detect raining outside, the LED lights up.