variable ramping
stilgar
Posts: 47
Could someone explain bit by bit how to ramp a variable. I did a search but did not find any info to answer my question.
I am wanting to understand this line of code. I know what it does but don't understand how it does.
volume := ++volume <# 32
in the program the line slowly raises the volume variable on my wav player.
I am also interested in how to decrease the variable as well.
thanks,
stilgar
I am wanting to understand this line of code. I know what it does but don't understand how it does.
volume := ++volume <# 32
in the program the line slowly raises the volume variable on my wav player.
I am also interested in how to decrease the variable as well.
thanks,
stilgar
Comments
http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/Web-PropellerManual-v1.2.pdf
volume := volume + 1
volume := volume <# 32
If you write volume++ in an expression, that's called a post increment. So, first the value of volume is read and used in the rest of the expression and then it is increased. This of course would not make sense in this expression.
stilgar
volume := --volume #> 0
Every time this line is executed 1 is added to the 'volume' variable up to a maximum of 32. I think it helps to learn to state a line of code in plain english.
As in the following example.
LED Throb - steps up and down by 2.
I always think of the "> <" symbols as hungry mouths. They're always open to the larger item, and when used as a limit they also get to eat a number sign.