# HELP! Urgent!

#### klz

##### New Member
hi all my group members and i need help for our project. There are two inputs, one input is for on/off, the other is for to change the motor patterns. If we would like to change another pattern, we depress the same button allocated for patterns. During the first sequence, if we would like to change to second sequence and if the button is pressed, it should go to the second sequence. But however, in our case, it doesn't work this way. For us, we would need to find the exact time when the first sequence ends then only can we press and change to second sequence. Attached is the flowchart. Please help! Urgent!

#### Attachments

• 65.7 KB Views: 26

#### hippy

##### Senior Member
Because of the "Wait 10" and Wait 2" the PICAXE will not detect button pushes during that time, 12 seconds. You need to respond to button pushes more quickly while keeping the output line as it should be.

In this case you have a cycled sequence which is high for 10 seconds then low for two. If you used a one second cycle you have a 12 step, one second cycle which could be done as -

-- Sequence1:
-- Do
---- For cycle = 1 To 12
------ If cycle <= 10 Then
-------- High 0
------ Else
-------- Low 0
------ End If
------ Wait 1
---- Next
-- Loop

You can then add a check for the button push every loop ( before the If ) and jump out of that looping code to the next sequence.

That checks the button every second. For even better button push response swap "Wait 1" for "Pause 1000", then reduce that to "Pause 100" and use "For cycle = 1 To 120" for a 120 step, 100mS cycle.

Sorry, I dont use the flowcharter, so you'll have to convert the given code if you want to do it in a flowchart.

#### klz

##### New Member
Thank you. I'll try it out.