RCX to RCX Communication
For two robots to communicate, one has to send a message and the other has to be prepared to receive the message. We will call one the sender and the other one the receiver. A Mindstorms™ robot can send a message to another robot, making it do whatever it is programmed to do when it gets the message. The infrared port that is usually used for downloading programs is also used to send messages.
In this activity you will learn how to program your robot to send a message to another robot. You will also figure out how to program the “other robot” to receive a message.
|
There is one way to send a message and many ways to receive one.
The Sender
You can have a send to RCX block anywhere in your program. When your program gets to that block, it will send out a number.
The Receiver
For a program to receive a message, it has to have either an IR watcher or one of the
IR Stack Decision Makers. It also has to set the condition for which numbers to accept.
|
IR Stack Decision Makers
|
Here are some examples of simple sending-receiving programs. These programs can work with many kinds of robots.
|
Sender Program
|
Receiver Program
|
Receiver Program
|
RCXtras
Remember you can always come up with a problem of your own to solve.
1. Recreate the sender program from the previous page. Change it so that it will send a message only after a touch sensor has been pressed or a light is shined on a light sensor. Have the receiver’s group program the robot to receive your message. (It is okay for the receiver to recreate the programs on the previous page.)
2. Write a program that has a robot return a message to the sender, making the sender do something. (A sender can also be programmed to be a receiver.)
3. Write a program that has the receiving robot respond to a message only after its touch sensor was pressed (or a light shined on its light sensor).