Shop OBEX P1 Docs P2 Docs Learn Events
Code for adjusting PAUSE time with a Potentiometer? — Parallax Forums

Code for adjusting PAUSE time with a Potentiometer?

SpragmaticSpragmatic Posts: 59
edited 2010-03-15 02:47 in BASIC Stamp
Is there a simple code for adjusting the PAUSE time with a potentiometer?· Thanks!

· Greg

Comments

  • rixterrixter Posts: 95
    edited 2010-03-15 01:57
    Greg,

    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
  • ercoerco Posts: 20,256
    edited 2010-03-15 02:10
    Greg: Easy as cake.

    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."
  • SpragmaticSpragmatic Posts: 59
    edited 2010-03-15 02:27
    Thanks Fellas!! I'm on it.

    Greg
  • SpragmaticSpragmatic Posts: 59
    edited 2010-03-15 02:47
    Just figured it and works great!! Thanks again guys!!

    Greg
Sign In or Register to comment.