Shop OBEX P1 Docs P2 Docs Learn Events
Storing and recalling the value of a variable — Parallax Forums

Storing and recalling the value of a variable

TonyATonyA Posts: 226
edited 2006-01-07 20:10 in BASIC Stamp
Hi,

I am using a pot (with RCTIME) to change the value of a variable. Is there a way I can store the current value of that variable with a switch and then "recall" that variable with another switch?

If anyone can point me in the right direction it would be greatly appreciated. Thanks again (and Happy new year).

Tony

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-07 19:02
    Are you wanting to store the value so that you can recall it after a restart? If yes, you can use WRITE with the Word modifier. To retrieve the value you would use READ, also with the Word modifier.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • TonyATonyA Posts: 226
    edited 2006-01-07 19:18
    Hi Jon,

    Yes, I would like to be able to record the value of the variable at any given time with the push of a button and then to retrieve it at any given time with another button.

    This is for my midi appilcations. I want to be able to preset sound bank changes. Like if using the sound patch "water bells", I can press a button and store it's value (127) and return to "water bells" at any given time by pressing a button rather than scrolling with my pot.

    Thanks again,
    Tony
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-07 19:35
    It's actually quite simple; you just need to be able to scan buttons in your main loop:

    · IF (StorePatch = Pressed) THEN
    ··· WRITE PatchAddr, patchVal
    · ENDIF

    · IF (RecallPatch = Pressed) THEN
    ··· READ PatchAddr, patchVal
    ····' do something with patchVal
    · ENDIF

    StorePatch and RecallPatch are button inputs, Pressed is a constant (0 or 1)·that defines the state of the input when a button is pressed, PatchAddr is the location in EEPROM you want to use to store the value, and patchVal is , of course, the sound patch (0 - 127).· By using WRITE for storage you can reset/restart the program and still have the stored value available for recall.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • TonyATonyA Posts: 226
    edited 2006-01-07 20:10
    Hi Jon,

    I see, yeah. That's all I need. Thanks again for your help, I really appreciate it.

    Tony

    Post Edited (TonyA) : 1/7/2006 8:21:04 PM GMT
Sign In or Register to comment.