Slider$
Slider$
Hi, I am new to Annex RDS.
I was trying to get the value of the variable sv in the following line as an example:
Slider$(sv,0,180)
All I got was the value 0; but the servo did move correctly. What is my mistake?
My code:
R = 12
sv = 0
servo.setup 1, R
html "Servo Angle => "
html "<cr>"
html "0 "
html slider$ (sv,0,180)
html " 180"
html " "
html sv 'Report the value of sv
loop1:
servo 1, sv
goto loop1
wait
end
I was trying to get the value of the variable sv in the following line as an example:
Slider$(sv,0,180)
All I got was the value 0; but the servo did move correctly. What is my mistake?
My code:
R = 12
sv = 0
servo.setup 1, R
html "Servo Angle => "
html "<cr>"
html "0 "
html slider$ (sv,0,180)
html " 180"
html " "
html sv 'Report the value of sv
loop1:
servo 1, sv
goto loop1
wait
end
-
- Posts: 143
- Joined: Mon Feb 08, 2021 10:10 pm
- Location: Scotland
- Has thanked: 47 times
- Been thanked: 51 times
Re: Slider$
Hi,
I am not an expert but this modified example may help.
Use a textbox to automatically display a variable when the html is refreshed.
There are better ways without using a loop but this might be a quick fix...
I am not an expert but this modified example may help.
Use a textbox to automatically display a variable when the html is refreshed.
There are better ways without using a loop but this might be a quick fix...
Code: [Local Link Removed for Guests]
R = 12
sv = 0
servo.setup 1, R
html "Servo Angle => "
html textbox$(sv) 'Report the value of sv
html "<br>"
html "0 " & slider$ (sv,0,180) & " 180"
loop1:
servo 1, sv
refresh
goto loop1
end
- cicciocb
- Site Admin
- Posts: 2069
- Joined: Mon Feb 03, 2020 1:15 pm
- Location: Toulouse
- Has thanked: 441 times
- Been thanked: 1364 times
- Contact:
Re: Slider$
Following the suggestion given by Bugs, this is my proposal :
Code: [Local Link Removed for Guests]
R = 12
sv = 0
servo.setup 1, R
gosub myPage 'load the web page at the first run
onHtmlReload myPage 'reload the web page automatically
while 1
servo 1, sv
wend
myPage:
cls
html "Servo Angle => "
html textbox$(sv) 'Report the value of sv
html "<br>"
html "0 " & slider$ (sv,0,180) & " 180"
autorefresh 250 'refresh automatically the variables each 250msec
return
end
- Electroguard
- Posts: 867
- Joined: Mon Feb 08, 2021 6:22 pm
- Has thanked: 278 times
- Been thanked: 324 times
Re: Slider$
In addition to the help from Bugs and Francesco you might find some useful info in this servo project which uses web sliders to control pan and tilt...
[Local Link Removed for Guests]
[Local Link Removed for Guests]
Re: Slider$
I tried your code. I am still getting value 0; but servo did moved correctly. But if I added refresh inside the while loop. It worked. Thank you.[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sun Mar 26, 2023 9:49 am Following the suggestion given by Bugs, this is my proposal :
Code: [Local Link Removed for Guests]
R = 12 sv = 0 servo.setup 1, R gosub myPage 'load the web page at the first run onHtmlReload myPage 'reload the web page automatically while 1 servo 1, sv wend myPage: cls html "Servo Angle => " html textbox$(sv) 'Report the value of sv html "<br>" html "0 " & slider$ (sv,0,180) & " 180" autorefresh 250 'refresh automatically the variables each 250msec return end
It also work if I add onHtmlChange myPage at the beginning of the program.
Last edited by andywong on Mon Mar 27, 2023 11:01 am, edited 3 times in total.
Re: Slider$
Thank you, It worked.[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sun Mar 26, 2023 9:28 am Hi,
I am not an expert but this modified example may help.
Use a textbox to automatically display a variable when the html is refreshed.
There are better ways without using a loop but this might be a quick fix...
Code: [Local Link Removed for Guests]
R = 12 sv = 0 servo.setup 1, R html "Servo Angle => " html textbox$(sv) 'Report the value of sv html "<br>" html "0 " & slider$ (sv,0,180) & " 180" loop1: servo 1, sv refresh goto loop1 end
Re: Slider$
Code: [Local Link Removed for Guests]
onHtmlReload myPage
onhtmlchange myPage
sv = 0
R = 0
servo.setup 1, R
gosub myPage
wait
myPage:
cls
servo 1, sv
html "Servo Angle => "
html textbox$(sv) 'Report the value of sv
html "<br>"
html "0 " & slider$ (sv,0,180) & " 180"
autorefresh 250 'refresh automatically the variables each 250msec
return
end
Re: Slider$
Thankyou, it works!
[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Mon Mar 27, 2023 9:44 am Thankyou, it works! Good example.