Esp8266 and 2 servos for camera position control, just a test.

Опубликовано: 06 Июль 2026
на канале: chaospage
6,212
19

More progress has been made, see:    • esp8266, internet camera position control,...  
This one here was done using pure lua. At the lua console I used the 4 lines shown below to setup 2 pins for PWM (pulse-with-modulation) and 2 timers to change the pulse with for each servo motor independently.

p0 = 4 pwm.setup(p0,50,70) pwm.start(p0)
p1 = 3 pwm.setup(p1,50,70) pwm.start(p1)
a0 = 30 d0 = 1 tmr.alarm(0, 13, 1, function() pwm.setduty(p0,a0) a0=a0+d0 if a0►125 or a0◄30 then d0=d0*-1 a0=a0+d0 end end )
a1 = 70 d1 = 1 tmr.alarm(1, 17, 1, function() pwm.setduty(p1,a1) a1=a1+d1 if a1►125 or a1◄30 then d1=d1*-1 a1=a1+d1 end end )