|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
ok......i have asked several questions about the turning of the arm......slowly but surely with all of your help our control team has figured out a simple program to make the arm turn with ONE BUTTON!!!! Thanx for everyone's help and please reply here or pm me if you have any questions!!! Our team will be glad to help out. Here is the code for everyone who needs it
![]() if logged = 1 then hopskipjump: if count1 = 1 then skippy: if p1_sw_top = 0 then out: if p1_sw_top = 1 then in: in: relay1_fwd = 1 relay1_rev = 0 count1 = 1 goto hopskipjump: out: skippy: if count1 = 0 then jumpy: if p1_sw_top = 0 then outy: if p1_sw_top = 1 then iny: iny: relay1_rev = 1 relay1_fwd = 0 count1 = 0 outy: jumpy: hopskipjump: logged = p1_sw_top |
|
#2
|
|||||
|
|||||
|
Re: Arm Rotation (1 Button Programming!!)
Hi Joel,
<shamelessplug> If you were using my BASIC Stamp Preprocessor (available in the wite papers section with additional information elsewhere in this Technical Discussion forum), you could rewrite your code thus to make it more understandable: Code:
{$if logged = 0}
{$if count1 = 0}
{$if p1_sw_top = 1}
relay1_fwd = 1
relay1_rev = 0
count1 = 1
{$endif}
{$else} ' count1 <> 0
{$if p1_sw_top = 1}
relay1_rev = 1
relay1_fwd = 0
count1 = 0
{$endif}
{$endif}
{$elseif}
logged = p1_sw_top
Now that I did that, and examined the code further, I'm not sure this code is going to do exactly what you want. Let me analyze what this code does: Code:
If the joystick thumb button was NOT pressed the last time we came through the loop, then (depending upon whether count1 is set or clear) either:
Code:
{$if prevButtonState = 0}
' The button was up the last time through the loop ...
{$if p1_sw_top = 1}
' ... but it's now being pressed, so do something:
{$if relayState = 0}
relayState = 1 ' Relay on forward
relay1_fwd = 1
relay1_rev = 0
{$elseif relayState = 1}
relayState = 2 ' Relay off. Next time reverse
relay1_fwd = 0
relay1_rev = 0
{$elseif relayState = 2}
relayState = 3 ' Relay reversed
relay1_fwd = 0
relay1_rev = 1
{$elseif relayState = 3}
relayState = 0 ' Relay off. Next time forward
relay1_fwd = 0
relay1_rev = 0
{$endif}
{$endif}
{$elseif}
prevButtonState = p1_sw_top
Last edited by Greg Ross : 14-02-2002 at 16:19. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| which button machine do you use and do you like it? | KenWittlief | General Forum | 10 | 16-10-2003 00:01 |
| Reflected Inertia? | archiver | 2001 | 9 | 24-06-2002 03:50 |
| Fingers and Robot Controller | archiver | 2001 | 4 | 23-06-2002 23:54 |
| Arm Turning (programming) | Joelster | Programming | 4 | 13-02-2002 21:35 |
| Light programming | punarhero | Programming | 15 | 12-02-2002 22:52 |