Saving Variables


Results 1 to 5 of 5

Threaded View

  1. #2
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Michael,

    M>What I want to do is when both buttons are pushed have it save the value of the delay variable to the microcontroller, so that when the microcontroller is restarted it will load this value for the delay rather than having to reset it every time. If this is possible how would I write the code for it and include it in my project.<<

    Well, you can save it in Eprom and load it from beginning. Here is a Psuedo code:

    HoldVar Var byte
    Button1 Var Port A.0
    Button2 Var Port A.1

    Read 0, HoldVar ;put EEprom in HoldVar

    Loop:
    if Button1=1 then
    pauseus 100
    If Button2=1 then
    Write 0, HoldVar
    HoldVar=HoldVar -1
    Pause 100
    endif
    HoldVar=HoldVar+1
    endif

    if Button2=1 then
    pauseus 100
    If Button1=1 then
    Write 0, HoldVar
    HoldVar=HoldVar +1
    Pause 100
    endif
    HoldVar=HoldVar-1
    endif

    Do whatever you want....
    goto Loop

    The Pauseus and Pause can be varied to a value that works for you...
    I know there are other ways to do this *=} But have fun.

    Dwayne
    Last edited by Dwayne; - 15th June 2005 at 22:01.
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

Similar Threads

  1. Saving variable(s) contents before power is removed
    By emavil in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 15th July 2007, 17:26
  2. 16F to 18F context saving differences
    By brittons in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st April 2007, 03:40
  3. Variables not appearing in Watch Window MPLabv7.3
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th June 2006, 14:36
  4. Problems with variables
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th December 2004, 18:37
  5. saving program variables
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 2nd November 2004, 22:25

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts