PROGRAMMING: GETTING STARTED
Exercise 3: Modifying the Program so that the WonderBorg can Pick Up and Follow an Infrared Signal
In this exercise, we’re going to modify the program from Exercise 2, so that if the robot detects an infrared signal, it will enter "Following mode (Panel 2)", and start following the infrared signal. This program uses 2 panels.
Program for Exercise 3
Panel 1
Add this Section to the program from Exercise 2.
Panel 2
Create a new panel: Panel 2 You can simply copy the blocks from Panel 1 to Panel 2, and then edit them.
Panel 1
Panel 1 was created by taking the program from Exercise 2 and augmenting it with a line telling the robot what to do if it detects infrared signal 2 (Way Point). If it detects this particular infrared signal, it is instructed to switch to the program on Panel 2. As a result of the tests you carried out in Exercise 2, your blocks for evasive action may look different from those shown above, but you do not need to alter the figures all over again.
Panel 2
Panel 2 contains a program for "Following mode", where the robot will follow infrared signal 2 (Way Point). If it detects this particular infrared signal, it is instructed to move forward 3 steps. If there is no sensor reaction, it must then turn one step to the right. In this program, if the robot loses the infrared signal, it will turn
49 | round and round, while if it finds it, it will move forward. |
|
PROGRAMMING: GETTING STARTED
Testing
Before sending the program to the robot and having it executed we are going to prepare to transmit infrared signal 2 (Guide to another robot) from the interface.
Click the "Set Up" button at the bottom right of the Panel screen, select "infrared signal 2 (Way Point)" from "IR Signal Control" menu on the Set UP screen, then click the "Start" button. The red indicator lamp on the Interface should flash for a short while, then the flashing will stop, and this pattern should be repeated continuously. If this happens, the infrared signal 2 is being transmitted from the interface.
If necessary, you can unplug the cable from the Interface, and place the Interface some distance away from your PC. When you do this, do not switch the Interface’s main switch OFF: the infrared signal will stop if you do so.
The range of the infrared signal is shown in the diagram below. Place the robot somewhere inside this range before starting the transmission. If the transmission does not work, move the robot a little closer to the Interface, then try again.
How to Transmit an Infrared Signal
1. Select the desired Signal by clicking the name.
2. When you click the "Start" button, the infrared signal will be transmitted to the robot.
3. To stop the transmission of the infrared signal, either click the "Stop" button, or start transmitting another signal. The transmission
will also stop automatically if you click "Download to WonderBorg" on the Settings screen, if you transmit a program by clicking "Download to WonderBorg" on the Panel screen.
The Ranged Reached by the Infrared Signal
Interface (front face)
max 1.5m
max 0.75m
Range reached by signal
Note: The range may vary depending on the brightness of the surroundings, and other
factors.50