... | ... | @@ -69,7 +69,6 @@ The first set of code is for the Micro:Bit controller. This controller waits for |
|
|
The second set of code is for the Micro:Bot robot. This Micro:Bit waits to receive a message. If they receive a "left" message, it tells the robot to go left. If they receive a "right" message, it tells the robot to go right.
|
|
|
|
|
|
## Step 3: Download The Files
|
|
|
---
|
|
|
* Download (click on) the following file to get started: [MicroBotLab.zip](/uploads/99bcb034cdee9aad07dcc403efcdbe35/MicroBotLab.zip)
|
|
|
|
|
|
* Unzip MicrobotLab.zip (right click on the MicrobotLab.zip and select "extract all". Then, just pick where you want to save your copy of these files). Notice there are three folders/directories in MicrobotLab:
|
... | ... | @@ -81,7 +80,6 @@ The second set of code is for the Micro:Bot robot. This Micro:Bit waits to recei |
|
|
![microbot_files](/uploads/55820c43e18aa35782b09b8757501741/microbot_files.PNG)
|
|
|
|
|
|
## Step 4: Open your editor
|
|
|
---
|
|
|
* For JavaScript/Blocks, you will use the Micro::Bit online editor: [MakeCode](https://makecode.microbit.org/). Here, you can switch back and forth between JavaScript and Blocks by clicking on the button/slider in the top center of the screen.
|
|
|
|
|
|
![blocks](/uploads/7061a5064100caa0790c714bdb1182c1/blocks.PNG)
|
... | ... | @@ -89,7 +87,6 @@ The second set of code is for the Micro:Bot robot. This Micro:Bit waits to recei |
|
|
* For Python, you can use Mu ([click here to see Mu](https://codewith.mu/)) or the online editor ([click here to get to the online editor](http://python.microbit.org/v/1)).
|
|
|
|
|
|
## Step 5: Get Moto-Bit library
|
|
|
---
|
|
|
* For JavaScript/Blocks, start by selecting the "Advanced" drop down box in the libraries toolbar.
|
|
|
|
|
|
![microbot_lib1](/uploads/8b8abbdeb2a7281e77d469955ce2fa39/microbot_lib1.PNG)
|
... | ... | @@ -107,9 +104,9 @@ You can check to make sure that you have the library by searching for the librar |
|
|
![microbot_lib4](/uploads/50880517646fef4065f781d017771d02/microbot_lib4.PNG)
|
|
|
|
|
|
## Step 6: Programming!
|
|
|
---
|
|
|
1. Partner up
|
|
|
2. Open the robot base code by:
|
|
|
### Complete the Robot Code
|
|
|
1. Open the robot base code by:
|
|
|
1. Go to the files you downloaded from above
|
|
|
2. Double-click on the JavaScript or Python folder
|
|
|
3. Right-click on robot_base (JavaScript) or robot_base (Python)
|
... | ... | @@ -119,7 +116,7 @@ You can check to make sure that you have the library by searching for the librar |
|
|
7. Delete all of the existing code in the editor
|
|
|
8. Paste your code into the editor
|
|
|
9. If you are using Blocks, to get back to blocks, you can select the Blocks button in the center-top of the page.
|
|
|
3. Complete the robot code. You will add channel choosing functionality and give the motobit commands after receiving a radio transmission from the controller:
|
|
|
2. Complete the robot code. You will add channel choosing functionality and give the motobit commands after receiving a radio transmission from the controller:
|
|
|
1. When button a and b are pressed, set the radio group
|
|
|
2. When button a is pressed, if the radio group has not been set, decrement the radio group by 1
|
|
|
3. When button b is pressed, if the radio group has not been set, increment the radio group by 1
|
... | ... | @@ -127,9 +124,10 @@ You can check to make sure that you have the library by searching for the librar |
|
|
5. When the command "stop" is received over the radio, stop the motobit
|
|
|
6. When the command "left" is received over the radio, drive the mototbit left
|
|
|
7. When the command "right" is received over the radio, drive the mototbit right
|
|
|
4. Generate your robot .hex file and flash your robot Micro::Bit. If you don't remember how to flash code to your Micro::Bit, see the instructions [here](how-to-flash).
|
|
|
3. Generate your robot .hex file and flash your robot Micro::Bit. If you don't remember how to flash code to your Micro::Bit, see the instructions [here](how-to-flash).
|
|
|
|
|
|
5. Open the controller base code by:
|
|
|
### Compelete the Controller code
|
|
|
1. Open the controller base code by:
|
|
|
1. Go to the files you downloaded from above
|
|
|
2. Double-click on the JavaScript or Python folder. Stick with the same language as you chose for the robot_base
|
|
|
3. Right-click on controller_base (JavaScript) or controller_base (Python)
|
... | ... | @@ -139,11 +137,11 @@ You can check to make sure that you have the library by searching for the librar |
|
|
7. Delete all of the existing code in the editor
|
|
|
8. Paste your code into the editor
|
|
|
9. If you are using Blocks, to get back to blocks, you can select the Blocks button in the center-top of the page.
|
|
|
6. Complete the controller base code. You will add channel choosing functionality and send radio commands depending on the buttons pressed:
|
|
|
2. Complete the controller base code. You will add channel choosing functionality and send radio commands depending on the buttons pressed:
|
|
|
1. When button a and b are pressed, if the radio channel has not already been set, set it. if the radio channel has already been set, send a "forward" command over the radio
|
|
|
2. When button a is pressed, if the radio group has not been set, decrement the radio group by 1. if the radio group has been set, send a "left" command over the radio
|
|
|
3. When button b is pressed, if the radio group has not been set, increment the radio group by 1. if the radio group has been set, send a "right" command over the radio
|
|
|
7. Generate your controller .hex file and flash your controller Micro::Bit. If you don't remember how to flash code to your Micro::Bit, see the instructions [here](how-to-flash).
|
|
|
3. Generate your controller .hex file and flash your controller Micro::Bit. If you don't remember how to flash code to your Micro::Bit, see the instructions [here](how-to-flash).
|
|
|
|
|
|
<details>
|
|
|
<summary>
|
... | ... | @@ -445,7 +443,7 @@ You can check to make sure that you have the library by searching for the librar |
|
|
|
|
|
<br></br>
|
|
|
|
|
|
6. Test your code.
|
|
|
### Test your code.
|
|
|
* Your robot should:
|
|
|
* Allow radio group selection on startup and allow locking that radio group in
|
|
|
* wait for commands from the controller
|
... | ... | @@ -453,7 +451,8 @@ You can check to make sure that you have the library by searching for the librar |
|
|
* Your Controller should:
|
|
|
* Allow radio group selection on startup and allow locking that radio group in
|
|
|
* send commands to the robot upon various button presses: a+b is "start" and "stop", a is "left", b is "right"
|
|
|
7. Now try to intercept other robots. Are you able to control another group's robot simply by changing what radio group you set your controller to?
|
|
|
### Hack
|
|
|
Now try to intercept other robots. Are you able to control another group's robot simply by changing what radio group you set your controller to?
|
|
|
|
|
|
|
|
|
## Step 7: Further Exploration
|
... | ... | |