Shop OBEX P1 Docs P2 Docs Learn Events
how do I use buttons to control digital potentiometers? — Parallax Forums

how do I use buttons to control digital potentiometers?

paulmccopaulmcco Posts: 1
edited 2005-04-01 19:04 in BASIC Stamp
What I have set up are two buttons and a AD5220 digital potentiometer connected to a BS2/IC.
I would like to use one button to make the digital pot go down(towards A terminal) and the other to make the digital pot go up(towards B terminal).
I need the two buttons to run at the same time( I need to be able to choose either up or down without using separate programming instructions. If you know of any way to do this please send an e-mail to lsm788@cs.com. Thanks!

-Paul

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-04-01 18:40
    Paul,

    ·· You can read more than one pushbutton at the same time by reading the port directly, then branching based on the value:

    Start:
       DO
          BRANCH INA, (Start, Move_Up, Move_Down)
       LOOP
     
    Move_Up:
       your code here
       GOTO Start
     
    Move_Down:
       your code here
       GOTO Start
    


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • The Dead BugThe Dead Bug Posts: 73
    edited 2005-04-01 19:03
    Paul,
    Ordinarily this should be a straightforward task:

    You have the stamp periodically check the state of the two buttons,
    If one changes, you determine which one,
    You pulse the digital pot accordingly.

    But your statement:

    ( I need to be able to choose either up or down without using separate programming instructions.

    Gives me pause. Can you elaborate on your requirement that you cant use "separate programming instructions"?
    Bruce

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Name: Bruce Clemens

    Work:· Clemensb@otc.edu
    Good Stuff on my Blog: http://theDeadBug.journalspace.com
  • edited 2005-04-01 19:04
    Take a look at What's a Microcontroller v2.2. If that's not what you're already working from, it's available for free download from www.parallax.com -> Downloads -> Stamps in Class Tutorials.

    In Chapter 2, Activity #4, there's a program called PushbuttonControlofTwoLeds. In Chapter 9, Activity #2, there's a program called DigitalPotUpDown.bs2.

    Take the elements of DigitalPotUpDown.bs2 that increment the AD5220's wiper up and down and insert them into the IF...ELSEIF...ELSE...ENIDIF statement in PushbuttonControlOfTwoLeds.bs2.

    When you're done, instead of pushbutton controlling LEDs, you will pushbutton control the digital potentiometer.
Sign In or Register to comment.