Need help with Picaxe command

joemahma

New Member
Greetings.!
This is pretty embarrassing guys and gals, but as a newb, getting back into this stuff after a hiatus of several years, I need help with a small piece of code. Here's what I'm trying to do?

I'm lighting a quad rotor and using TWO different "programmed bits of code" to achieve my purpose. Both little programs work well on their own, but I need to know how to get ONE flash pattern to engage for let's say 10 seconds, and then the first one stop and the SECOND one to activate for about the same duration, and then repeat, going back to the FIRST bit of code. I know there's a way to DO it, but I don't have the knowledge to achieve it. Can you help? If so, I'll be deeply grateful. I've received help in the past from forum members, and the quality and willingness of the helpers was remarkable. I hope that goodwill still exists. Am enclosing (I hope) the two code snippets that I want to run, first one, and then the other, over and over.

Thanks much,
joemahma

PS Have been trying to attach these two bits of code and having a HARD TIME doing it! Is there some special trick to it?
 

oracacle

Senior Member
try putting your ocde it a note pad and uplaoding, or post in code tags.

do you know how long each flash takes?

you can use a for...next loop. so if each flash takes 0.5 seconds:

for b0 = 0 to 20
'do flashy bit
next bo

do that for both flash programmes and then a goto main at the end and all will start again
 

Goeytex

Senior Member
To add code, select the code in the Program Editor then "copy for forum". Next paste the code into your post.

If done correctly the code will be bracketed by the [code] [/code] tags

Example

[code]
high 1
pause 1000
low 1
[/code]
 

geoff07

Senior Member
A simple structure for your code might be:
Code:
DO
   call first_flash
   call second_flash
LOOP

first_flash:
   return

second_flash:
   return
Then, in each of the subroutines place the code for the individual parts, making sure that the subroutine takes care of the timing.

If you want clock timing rather than simply loop counting you can use the 'time' variable (on an M2 part):

time = 0

if time > x then
time = 0
whatever
endif

That could be the basis of a solution, though you still have work to do.
 

hippy

Technical Support
Staff member
If using an M2 device you can have one sequence in one task, the other in a second task, and use a third task to select between which of the display sequence tasks to run.

That's probably a good solution if you want specific times and forced change to the other sequence at those times. Some of the earlier suggestions may be better if you only want changes between sequences at certain points in those sequences so they are less jarring.
 
Top