<p>You just need to make the blocks match your pseudo code. The missing part is "Stop Motor B". Adding blocks to stop motor B will help.</p>

<p>Also, stop motor B needs to be before starting motor A, otherwise motor A will run while motor B is running.</p>

<pre><code>If Touch1 == Bumped Then
    Stop MotorB
    Rotate MotorA by 15 degrees
Else If Touch2 == Bumped Then
    Stop MotorB
    Rotate MotorA by -15 degrees
Else
    Rotate MotorB Forever
</code></pre>

<p><a href="https://i.sstatic.net/1sKgw.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/1sKgw.png" alt="enter image description here"></a></p>

CC BY-SA 3.0
2016-08-22T23:51:36.700Z
2016-08-22T23:51:36.700Z
David Lechner
<p>Ok, so I have this automatic gearbox I have made and I have 2 motors and 2 touch sensors</p>

<p>I want Motor A to spin forever unless Motor B is turning</p>

<p>Motor B should turn around 15 degrees and then brake. The direction depends on what touch sensor is pushed. I created this piece of block code thing (personally don't like) but it looks like it should work but it doesn't.</p>

<p><a href="https://i.sstatic.net/QuVTD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/QuVTD.png" alt="enter image description here"></a></p>

<p>Motor A spins forever and when B is activated, it spins forever too completely destroying the gearbox :(</p>

<p>Pseudo Code:</p>

<pre>If Touch1 == Bumped Then
    Stop MotorB
    Rotate MotorA by 15 degrees
Else If Touch2 == Bumped Then
    Rotate MotorA by -15 degrees
    Stop MotorB
Else
    Rotate MotorB Forever

(I know this is horrrible pseudo code but you get the jist)
</pre>

<p>What am I doing wrong???</p>

CC BY-SA 3.0
2016-08-22T23:53:20.287Z
Your text description does not match the picture or pseudo code - motor A and motor B are mixed up. You should fix that for future readers. Also, your pseudo code is not horrible, it is perfectly clear.
David Lechner
<nxt><motor><nxt-g>
NXT Program doesn't do what it's supposed to do
CloudSync
# NXT Program doesn't do what it's supposed to do

(Asked by: username_0 on 2016-08-22)

Ok, so I have this automatic gearbox I have made and I have 2 motors and 2 touch sensors
I want Motor A to spin forever unless Motor B is turning
Motor B should turn around 15 degrees and then brake. The direction depends on what touch sensor is pushed. I created this piece of block code thing (personally don't like) but it looks like it should work but it doesn't.

Motor A spins forever and when B is activated, it spins forever too completely destroying the gearbox :(
Pseudo Code:
If Touch1 == Bumped Then
    Stop MotorB
    Rotate MotorA by 15 degrees
Else If Touch2 == Bumped Then
    Rotate MotorA by -15 degrees
    Stop MotorB
Else
    Rotate MotorB Forever

(I know this is horrrible pseudo code but you get the jist)

What am I doing wrong???

**Tags:** nxt, motor, nxt-g

> **Comments:**
> **username_1**: Your text description does not match the picture or pseudo code - motor A and motor B are mixed up. You should fix that for future readers. Also, your pseudo code is not horrible, it is perfectly clear.  

---

## 1 answers

### Answer by username_1 on 2016-08-22. Score: 1

You just need to make the blocks match your pseudo code. The missing part is "Stop Motor B". Adding blocks to stop motor B will help.
Also, stop motor B needs to be before starting motor A, otherwise motor A will run while motor B is running.
If Touch1 == Bumped Then
    Stop MotorB
    Rotate MotorA by 15 degrees
Else If Touch2 == Bumped Then
    Stop MotorB
    Rotate MotorA by -15 degrees
Else
    Rotate MotorB Forever


---

