Variable within Variable


Results 1 to 6 of 6

Threaded View

  1. #3
    Join Date
    Nov 2008
    Posts
    22


    Did you find this post helpful? Yes | No

    Default

    I think an array may work, I'm playing with it now.

    To answer your question mark at the end of the message, essentially I have three sensors which need calibration and one button used to do the calibration. The three sensors calibration values are stored in variables (Data_Sen1, Data_Sen2, Data_Sen3). I wanted to write the code so it "loops" and which sensor you're calibrating is changed with a certian button push. I didn't want to write extra code for each sensor when I could do it in a loop.

    The calibration flow is as follows:

    -Enter the calibration loop
    system ready to cal sensor 1 (Data_Sen1)
    cal direction set to up (increase value)
    -if you push the button once, cal value increases by one.
    -if you push the button twice, cal direction switches to down (decrease value)
    -subsequent single button pushes decrease the cal value.
    -if you push the button three times, the program moves onto the next sensor (Data_Sen2).
    -push the button four times and we exit the calibration loop.

    It looks like I could use sensor variables in an array such as Data_Sen[i] and alter the value of i as I move through the program.

    I'm pretty sure I've used this before and just forgot, thanks for the reminder. I also recall that setting up an array such as:

    Data_Sen var byte[3] would give Data_Sen[0] thru Data_Sen[2]. I'd need to setup Data_Sen var byte[4] if I wanted to use the numbers [1] -> [3]

    Mark
    Last edited by munromh; - 7th January 2009 at 19:10.

Similar Threads

  1. EEPROM Variables (EE_Vars.pbp)
    By Darrel Taylor in forum Code Examples
    Replies: 79
    Last Post: - 26th October 2012, 01:06
  2. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 07:03
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 21:36
  4. WORD vs BYTE variable lengths
    By bartman in forum General
    Replies: 0
    Last Post: - 28th November 2005, 22:16
  5. Storing a variable in EEPROM
    By Tissy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 29th October 2005, 14:53

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