Small help needed

69-cat

Member
I am starting on some Halloween projects and wanted to make a "simulated" rotating tunnel that people would walk through. Basically a tube with chasing lights to simulate the tube was spinning. So I made a simple program with 10 outputs, connected to triacs for the strings of light (40 total). I started out with a "Pause 20" between the high, lows but wanted to add a pot to control the speed. I added ADC but it does not control the speed. When I use this ADC on a single output, the pot works fine. Is it because I am for lack of a better work sharing the ADC "b5" task?
Dave
 

Attachments

hippy

Technical Support
Staff member
One problem may be with ...

for b0 = 1 to 2000

Byte variables can only contain values 0 to 255 so b0 will never reach 2000.

Change the byte variable from 'b0' to 'w0' and things may work better.

Though having said that, when b0 increments past 255 it should rollover to 0 and be less than 1 which would terminate the FOR-NEXT loop.

It may help if you could describe exactly what the code does when it is behaving other than as expected; in what way can the speed not be changed.
 

69-cat

Member
I was using the 1 to 2000 to control how long the sequence ran so I would not need a second PIR for the Exit side of the tunnel. That part seems to work OK.

The speed change I was hoping to have would be fine tuning the effect of the spinning lights. This way I could dial in the effect needed, faster or slower after the prop is installed.


Dave
 

hippy

Technical Support
Staff member
Are you trying to change the speed of lights while the tunnel is activated ?

If so then you would need to move the READADC to within the FOR-NEXT loop. As it is now, the speed pot is only read when the tunnel is activated.
 

BESQUEUT

Senior Member
I am starting on some Halloween projects and wanted to make a "simulated" rotating tunnel that people would walk through. Basically a tube with chasing lights to simulate the tube was spinning. So I made a simple program with 10 outputs, connected to triacs for the strings of light (40 total). I started out with a "Pause 20" between the high, lows but wanted to add a pot to control the speed. I added ADC but it does not control the speed. When I use this ADC on a single output, the pot works fine. Is it because I am for lack of a better work sharing the ADC "b5" task?
Dave
As it is, lines
15: GOTO PIR
20: GOTO main

are totaly useless ! (I think program will be the same if you remove them)
==> less confusion and more readable.

As said by Hippy, the for next loop will never reach 2000 as b0 cannot be more than 255.
But if 2000 is interpreted as a byte, It can be 2000 MOD 256=208

So the FOR/NEXT may be actually :
- a never ending "DO LOOP"
- or a FOR b0=1 TO 208 Loop

Tried with Simulator :
Code:
for b0=1 to 2000
	sertxd(#b0," ")
next b0
sertxd ("END",13,10)
==> Never ending loop
I don't know what will do a real Picaxe.
 
Last edited:

69-cat

Member
Yet another good feedback! Funny, what I thought "b0 2000" was working come to find out my batteries on my "portable" proto board were weak and when I would go back to check to re trigger the board, there must have been just enough voltage to trigger, I would walk away only to come back and see what I thought was timed out was now a dead battery pack! Lesson learned on weak to dead batteries.....I am now using a wall pack for power!
Dave
 

BESQUEUT

Senior Member
when b0 increments past 255 it should rollover to 0
YES
and be less than 1 which would terminate the FOR-NEXT loop.
? I do not agree, at least with simulator.
User manual say "When the end value is exceeded the looping stops"
To reach zero, you must use the STEP -1 syntax (or use the trivial one step loop : FOR b0 =0 to 0)
 
Last edited:
Top