subtract 3 from BTotal.
• Select the entire program
and go to Edit > Make
a New My Block, and
finish the My Blockcreation
process. I recommend
naming this block B
• Now, create the exact
same program except use
C for everything. Motor
Port C, CLast, CDiff,
CTotal, and name it C
of your variables on the NXT screen. In this
screenshot, I viewed BTotal to verify that it was
returning the numbers I wanted, and it wasn't
malfunctioning. More on this later!
• Now, add the two My
Blocks to your Isotope
Control program as
indicated in the image.
• Download the Isotope
Control program to the
remote control you built
last month. Download the
Isotope Bot program to
• Connect the two NXTs via Bluetooth, and give the
programs a run.
The Tricky Part
Refer to Figures 5 and 6.
Now, we're going to need to create two My Blocks.
These are custom blocks you can use in your program
that are part of the main program, but are too big and
need their own space to keep from making the program
• Create a new program. Add the number variables:
BLast, BDiff, and BTotal.
• Read variable BLast and use the Rotation Sensor
block to read the motor on port B of your controller.
Subtract BLast from the current motor reading and
write the result to BDiff. Now, write the motor
reading on port B to BLast.
• Add variables BTotal and BDiff together and write the
result to BTotal. Then, read BTotal and run it through
a Compare block to see if it's less than 0. Attach the
result to a logic switch.
• In the true section of the logic switch, add 3 to
BTotal. In the false section of the logic switch,
Isotope should have its normal forward/turn/stop
obility using the NXT buttons on the controller, but now
spinning the motors on the controller should cause
Isotope's linear actuators to move in and out proportionally
based on how much you spin them.
Undertstanding the Program
This is by a good margin the most complicated
program we've done to date in The NXT Big Thing, so bear
with me as I try to break down what happens.
Let's look at the control program. Specifically, let's look
inside our B Hydraulic Control My Block. The first thing to
understand is that we need to be able to compare the
current state of the motor on port B to its state the last
time the My Block was run (in this case, it runs every . 10
seconds in our main program). By comparing its current
state to its "BLast" state, we can find the difference
between the two, and understand how far the motor has
turned since we last recorded a change. This way, we know
exactly how far the motor has moved in total which is
important in telling Isotope how far to extend or contract
72 SERVO 02.2012