Altering a variable in a loop.


Results 1 to 27 of 27

Threaded View

  1. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Altering a variable in a loop.

    Hi,
    Several ways to do it, as usual. Here's one:
    Code:
    ' Setting is your variable that step or down between 0-5
    Lookup Setting, [12, 30, 55, 76, 98, 120], BaseDutyCycle
    Another way would be to not step the Setting variable between 0 and 5 but to actually step it directly between dutycycle values
    Code:
    Select Case Step
      Case 12
        IF DOWN THEN
           Setting = 12 ' We're at the bottom setting
        ELSE
           Setting = 30
     
      Case 30
         IF DOWN THEN
            Setting = 12
        ELSE
           Setting = 55
        ENDIF
    
    'And so on
      END SELECT
    
    PWMDuty = Setting
    /Henrik.
    Last edited by HenrikOlsson; - 12th September 2012 at 20:43.

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