Code for adjusting PAUSE time with a Potentiometer?
Spragmatic
Posts: 59
Is there a simple code for adjusting the PAUSE time with a potentiometer?· Thanks!
· Greg
· Greg
Comments
One way to do this is by using an RCTIME circuit (see PBASIC command). What you could do is to have the RCTIME code at the beginning of your program or in a subroutine and use a multiplier to get a variable result that lines up with the pause values you desire. The pause command can take a variable for it's argument, so you would set that variable in your RCTIME result calculations. As an example, a 10K POT with a 220 k resistor in combination with a .01 mf capacitor yields an RCTIME value of between 1 - 56 in my tests. Multiplying this value by 100 for example would give you a pause range of 100 to 5600. You can experiment with different caps. Larger caps will give higher RCTIME numbers and consequently more flexibility in your final pause value variable.
' RCTIME circuit set up on pin 1
time VAR Word
per VAR Word
HIGH 1
PAUSE 100
RCTIME 1,1, time
per=time*100
PAUSE per
Hope this helps.
Rick
Whatever your program is, you'll have to be looping through over & over again. One of your commands will RCTime (or POT with a BS1) your pot, to return a value based on the potentiometer setting. That value can be a byte or word, depending on how you define that variable. Get that going first, throw in a temporary DEBUG statement so you can see the value changing as you adjust the pot. Once you see the values returned by RCTime, do whatever math you need to adjust the value to a useable value in a PAUSE statement. Once you're done, remove the DEBUG statement, which slows down your program.
Piece of pie.
Edit: I snoozed and Rick nailed it!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Greg
Greg