Data Sheet
22
Open the LuaLoader, click the “Upload File…”choo se ESP8 266 NodeM CU kit demo
code -> P10_Breathing_Lamp -> init.lua. After the upload completed then click “Download ” to
download the init.lua file.
Demo Code:
print("Breathing Lamp Start")
pwm.setup(1,1000,1023); -- set pot 1 PWM mode frequency 1000hz and the duty cycle 1023pwm.start(1);
tmr.alarm(2,100,1,function() --Timer 2 using the timing 100ms Repeatability
local r=adc.read(0)
if(r<1024) then -- the most analog read is 1024 but the most PWM’ suty cycle is 1023
pwm.setduty(1,r); -- set the port 1 PWM’s duty cycle is “r”
else
pwm.setduty(1,1023);
end
end)
The LED will lighten or darken with the Rotary Angle Sensor forward or reverse rotate.
11. Lesson11 Laser Pointer
This laser pointer or laser pen is a small handheld device with a laser diode emitting , it is
frequently used in lecture halls and demonstrations to point at topics of interest on a
presentation board. But please note that DO NOT Point this module to eyes directly.
Material:
Crowtail- ESP8266 NodeMCU x 1
Crowtail- Switch x 1
Crowtail- Laser Pointer x 1
Hardware Connection
Open the LuaLoader, click the “Upload File…” to choo se ESP8266 NodeM CU kit de mo
code -> P11_Laser_Pointer -> init.lua. After the upload completed then click “Download ” to
download the init.lua file.
Demo code:
a=gpio.read(2)
while (1) do
if (a==1) then
gpio.write(1,gpio.HIGH)
else