Figure 3. Add a Variable block set to Read, a Number To Text
block, and a Display block, all wired up as indicated to display
the VarX variable.
Figure 4. Finally, add a . 2 second wait at the end.
Putting It All Together
Download the control program to your controller and
the receiver program to Eddie. Then, connect the NXTs via
Bluetooth and run both programs. Remember not to move
the control while it’s calibrating!
If all goes well, swinging the controller left and right
should decrease and increase the number displayed on
Eddie’s screen. You may also want to have Eddie display
Var Y to make sure that it’s working properly, too.
The Final Touch
Alrighty, roboteers. So far, we’ve learned about gyro
sensors, hacked them to give us a value we can use,
created a handheld Bluetooth controller using our hacked
sensors, written a program to send out sensor values to
Eddie, written a program to receive the sensor values on
Eddie, and we aren’t even finished yet!
The last thing we need to do is make Eddie react to his
sensor values. It’s actually pretty simple.
Gyro Receiver Final Instructions
Figure 1. Save your Gyro_Receiver_Test program as
Gyro_Receiver_Final. Then, delete the Number To Text and
Figure 2. Add two variable blocks. Set the first to read Var Y
and the second to read VarX. Add a move block, and run Var Y
to the Power data hub and VarX to the Steering data hub.
Finally, set the motor duration to Unlimited.
SERVO 08.2011 73