I'm trying to program something that uses the picoboard in a very certain way:
if the picoboard slider goes from value 0 to value 100, increase tameness.
In short, if you slide the picoboard from one side to the other, do something.
Even though this seems relavitely simple, I can't seem to figure out how to do it. I've tried the following scripts:
[scratchblocks]
when gf clicked
forever
if <(slider-sensor-value)> = [0]
if <(slider-sensor-value)> = [100]
change <(tameness)> by [10]
if <(slider-sensor-value)> = [100]
if <(slider-sensor-value)> = [0]
change <(tameness)> by [10]
end
[/scratchblocks
[scratchblocks]
when gf clicked
forever
if <(slider-sensor-value)> = [0]
wait until <(slider-sensor-value)> = [100]
if <(slider-sensor-value)> = [100]
change <(tameness)> by [10]
if <(slider-sensor-value)> = [100]
wait until <(slider-sensor-value)> = [0]
if <(slider-sensor-value)> = [0]
change <(tameness)> by [10]
end
[/scratchblocks
postblocks. Somethings wrong with the scratch blocks... more then just the way they appear? What is it?
but none of them are working! Any suggestions?
Last edited by horsenkat (2012-02-16 17:06:26)
Offline
You need to close the scratchblocks tag with ] at the end of the [/scratchblocks
I think the trouble you are running into is that your embedded ifs only check once, for a single instance- they don't wait until they are true.
Try something like this:
when gf clicked forever if <<(slider-sensor-value) = [0]> OR <(slider-sensor-value)= [100]>> wait until <not <(slider-sensor-value) = [0]> OR <(slider-sensor-value)= [100]>> wait until <<(slider-sensor-value) = [0]> OR <(slider-sensor-value)= [100]>> change <(tameness)> by [10]Actually, this will register a change even if one moves from 0 to 1 and back to 0. But you may need to use a variable to toggle the state.
Offline
Lightnin wrote:
when gf clicked forever if <<(slider-sensor-value) = [0]> OR <(slider-sensor-value)= [100]>> wait until <not < <(slider-sensor-value) = [0]> OR <(slider-sensor-value)= [100]> > > wait until <<(slider-sensor-value) = [0]> OR <(slider-sensor-value)= [100]>> change [tameness v] by [10]
Fixed your script.
This script could also be useful if you wanted to make some kind of game where you have to slide it back and forth as fast as possible.
Last edited by Lucario621 (2012-02-16 21:01:31)
Offline
I tested this script with a real PicoBoard.
It seems a little bit change required as follows.
when gf clicked forever wait until < < (slider-sensor-value) < [1]> or <(slider-sensor-value) > [99]> > wait until < not < <(slider-sensor-value) < [1]> or <(slider-sensor-value) > [99]> > > change [tameness v] by [10] endThe sensor values are not stable at the microscopic level. The monitor reflects rounded values. So equal operator is not suitable for comparing sensor value with other value.
Last edited by abee (2012-02-17 00:52:03)
Offline