Place to put your Basic demos and examples

Moderator: Mmiscool

User avatar
By heckler
#61969 Hey Group,
from Mike and Electroguard's code over here...
viewtopic.php?f=40&t=4849&p=61967#p61967

I modified it slightly to create an easy servo tester...

enjoy!
dwight

Code: Select allcls
let pinNo = 2
let Servo = 90
print "Control PIN"
textbox pinNo
print " Servo"
textbox Servo
slider Servo,0,180
timer 200, [SetServo]
button " Exit ", [TestExit]
wait

[SetServo]
io(servo,pinNo,Servo)
wait

[TestExit]
end     

' See more at: http://www.esp8266.com/viewtopic.php?f=41&t=13608
User avatar
By flywire
#62048 What is the minimum hardware setup to test this with a LoLin NodeMcu V3 Dev Board? I've got a few old DVD drives laying around as a donor servo motor.
User avatar
By heckler
#62112 Hi flywire,

So the "Servo" that this code works with is a standard RC type hobby Servo.
Not sure what it would take to implement a Servo Motor.

If you are unfamiliar with RC Servos just Goooooogle "RC Servo PWM" for info.

The code is simple to test out just load it on your favorite (handy) ESP module, hook up an O-Scope to the defined output pin and you will see a standard Servo PWM signal.

See the next post for the latest version of the code.
dwight
User avatar
By heckler
#62113 Latest version here... Allows you to change the limits that the slider will go. Also has Plus and Minus step buttons (that also cause the slider to move!! So COOL!!) :mrgreen:

As I am shaking my head in amazement at how easy it is to implement projects using this amazing espBASIC!!

Code: Select alllet LL = 0
let RL = 180
let Servo = 0
let Step = 1
[Main]
cls
let pinNo = 2
wprint "Output PIN "
textbox pinNo
html "<BR>"
wprint "Left Limit    = "
textbox LL
html "<BR>"
wprint "Right Limit = "
textbox RL
html "<BR>"
wprint "Enter desired slider limits above"
html "<BR>"
wprint "then click here --> "
button "New Limits", [Main]
html "<BR>"
html "<BR>"
wprint LL
slider Servo,LL,RL
wprint RL
html "<BR>"
html "<BR>"
wprint " Servo Now = "
textbox Servo
html "<BR>"
html "<BR>"
wprint "Step "
textbox Step
button "- - -", [Dec]
button "+ + +", [Inc]
timer 200,[SetServo]
html "<BR>"
html "<BR>"
button " Exit ", [TestExit]
wait
[Inc]
Servo = Servo + Step
if Servo > RL then Servo = RL
goto [SetServo]
[Dec]
Servo = Servo - Step
if Servo < LL then Servo = LL
[SetServo]
io(servo,pinNo,Servo)
wait
[TestExit]
io(servo,pinNo,LL)
end


Image