Test IR Circuits and Charge at the Opponent
In this activity, you will build and test IR object detection circuits and then write a script to make the cyber:bot charge an opponent based in object detection.
Example Script: cyberbot_sumo_ir_test
- Open cyberbot_sumo_avoid_edge with the micro:bit Python Editor.
- Change the project name to cyberbot_sumo_ir_test.
- Enter the script below into the micro:bit Python editor, then click Save.
Tests
- Connect the cyber:bot to the computer with the USB cable.
- Click the Send to micro:bit button to load the script into the micro:bit.
- (The cyber:bot can be left connected OR disconnected from USB at this point.)
- Set the PWR switch to 1.
- Set the cyber:bot on the sumo ring with both infrared detectors pointing away from any nearby objects.
- Verify that both IR indicator lights are on.
- Place an object in front of the right IR detector and verify that the right IR indicator light turns off.
- Place an object in front of the left IR detector, and verify that the left IR indicator light turns off.
- Place an object in front of the left IR detector, and verify that the left IR indicator light turns off.
- Place an object in front of both IR detectors, and verify that the both indicator lights turns off.
Troubleshooting
If the lights do not behave as expected, double check all electrical connections and each line of code.
Test for Infrared Interference
Follow the instructions in the Check for IR Interference page.
Sensitivity (Distance) Adjustments
This will be important
Follow the instructions in the Series Resistance and Range page. Return here when you are done.
Try Other Infrared Navigation Examples
Here are some general infrared navigation examples:
Adjust IR LEDs to Point Straight Ahead
For best results against a competitor, adjust the IR LEDs and receivers so that they point straight ahead.
Try This: Infrared Charger Mode
- If it’s not already open, click the Open button and reopen cyberbot_sumo_ir_test
- Set the project name to to cyberbot_sumo_ir_charger.
- Enter the script below into the micro:bit Python editor, then click Save.
- Disconnect the cyber:bot from USB, set it on the floor, and set PWR to 2.
- Verify that the cyber:bot chases your hand:
- If neither or both IR detectors see an object, the cyber:bot should roll straight forward.
- If one IR detector sees an object, it should turn toward that detector.