Data Sheet
32
Xn=bit.band(0x1000, Xaxis)
Yn=bit.band(0x1000, Yaxis)
Zn=bit.band(0x1000, Zaxis)
--If negative, convert twos complement number to decimal(-8193=-8192-1)
if Xn==4096 then Xaxis=Xaxis-8193 end
if Yn==4096 then Yaxis=Yaxis-8193 end
if Zn==4096 then Zaxis=Zaxis-8193 end
--4mg/LSB, multiply by 4, should divide by 1000
Xaxis=Xaxis*4
Yaxis=Yaxis*4
Zaxis=Zaxis*4
print(Xaxis)
print(Yaxis)
print(Zaxis)
end
tmr.alarm(2, 2000, 1, function() adxl() end )
After successfully download this file you will see the measuring accelerometer of x,y,z
direction in the debug window of LuaLoader.
Lesson16: Servo Control
In this lesson, we will learn how to realize 9G servo control, and how to let it rotate. 9G servo
need a 50HZ PWM, and the HIGH level’ duty cycle of this 20ms PWM, will decide the direction of
the rotation.
Material:
Crowtail- ESP8266 NodeMCU x 1
Crowtail- 9G Micro servo 9G x 1
Smart Phone x1