Data Sheet

15
to realize it. When pressed the button, the led was lighten and turn off when released.
Material:
Crowtail- LED x 1
Crowtail- Button x 1
Crowtail- ESP8266 NodeMCU x 1
Hardware Connection
Open the LuaLoader, click the “Upload File…” and choose ESP8266 NodeMCU kit dem o
code -> P02_Button_Control_Led -> init.lua. After the upload completed then click “Download
to download the init.lua file.
Demo code:
gpio.mode(1,gpio.OUTPUT) --Setup the port mode
gpio.mode(2,gpio.INPUT)
while(1) do
gpio.read(2) -- read port 2(gpio4)
tmr.delay(200000) --Delay 0.2 s
if (gpio.read(2)==1) then
gpio.write(1,gpio.HIGH) -- set the port 1 high level
end
if (gpio.read(2)==0) then
gpio.write(1,gpio.LOW) --set the port 1 low level
end
end
When you press the button, the led lighting , the led out when loosen the button.
Lesson3: Moisture Sensor
Do you want to know if your pet plant need some water in garden? This Moisture sensor can
help you. This Moisture Sensor can be used to detect the moisture of soil or judge if there is
water around the sensor, let the plants in your garden reach out for human help. They can be
very easy to use, just insert it into the soil and then it will read . With the help of this sensor, it
will be realizable to make the plant remind you : hey, i am thirsty now, please give me some
water.
Material:
Crowtail- Moisture sensor x 1
Crowtail- ESP8266 NodeMCU x 1
Hardware Connection