I'm somewhat stumped with the following piece of code. I want to fire a series of flashes with a predetermined delay inbetween. But somehow I can't get the delay code to work. Here's what I really wanted to code:
where flash_delay is guaranteed to always be a number between 1 and 99, thus making the pause well below the maximum of 65535. For example, with a value of flash_delay = 40, the delay should be four seconds.
However, the pause doesn't appear to be executed, or maybe flash_delay isn't being multiplied with 100, or whatever happens.
The following code works, however, where instead of using the calculated pause_length in line 4 above, I loop a number of 100 ms pauses in lines 3 through 5:
I suspect that pause may require an immediate operand and doesn't support register-direct addressing, but I can't gather this information from the manual.
Can anyone explain to me what I'm doing wrong in the first version?
Code:
[1] pause_length = flash_delay * 100
[2] for j = 1 to number_of_flashes
[3] pulsout 1, 100 ' 1 ms pulse
[4] pause pause_length
[5] next j
However, the pause doesn't appear to be executed, or maybe flash_delay isn't being multiplied with 100, or whatever happens.
The following code works, however, where instead of using the calculated pause_length in line 4 above, I loop a number of 100 ms pauses in lines 3 through 5:
Code:
[1] for j = 1 to number_of_flashes
[2] pulsout 1, 100 ' 1 ms pulse
[3] for k = 1 to flash_delay
[4] pause 100
[5] next k
[6] next j
Can anyone explain to me what I'm doing wrong in the first version?
Last edited: