Using Variables with PAUSE/PWM Commands
I want to be able to set a PAUSE value using a variable at the top of my code so that the same value can be referenced in many places and I only have to change it in one place while experimenting.
FLASH_ON VAR BYTE
FLASH_OFF VAR BYTE
FLASH_ON = 1500
FLASH_OFF = 500
lblLoop:
High LED_0
Pause 1500
Low LED_0
Pause 500
GoTo lblLoop
But this doesn't work, or at least the PAUSE doesn't last as long as I think it should (1.5 seconds the first instance, 0.5 the second).
Can you use variables with PAUSE? If so, are they defined as different types?
What about PWM? I'd like to do the same thing for the Duty & Cycle values.
Re: Using Variables with PAUSE/PWM Commands
Should I be using instead:
Symbol FLASH_ON = 1500
Symbol FLASH_OFF = 500
Re: Using Variables with PAUSE/PWM Commands
Quote:
FLASH_ON VAR BYTE
FLASH_OFF VAR BYTE
Your values are larger than a BYTE.
Re: Using Variables with PAUSE/PWM Commands
Yeah, they need to be WORD-size variables to fit values larger than 255....
But if you're not going to change the value at runtime there's no real need to have them as variables, you might as well make them constants:
Code:
FLASH_ON CON 1500
FLASH_OFF CON 500
Saves on both RAM and flash memory.
Re: Using Variables with PAUSE/PWM Commands
Thanks all! I'll use constants for now but eventually it will read from a pot input.