mbot:lesson2
Differences
This shows you the differences between two versions of the page.
mbot:lesson2 [2023/10/14 16:12] – created jstruebel | mbot:lesson2 [2023/10/14 17:00] (current) – jstruebel | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Objective ===== | ||
+ | This lesson will show you how to program the mBot to avoid obstacles. It will then show you how test your program on the mBot. | ||
+ | |||
+ | ===== Parts Required ===== | ||
+ | |||
+ | The parts below are required to complete this lesson. Note that all parts except the styrofoam blocks are included in the [[https:// | ||
+ | |||
+ | - Assembled mBot from [[: | ||
+ | - USB Cable | ||
+ | - Styrofoam Blocks that are at least 5in tall and 2in thick | ||
+ | |||
+ | ===== Software Programming ===== | ||
+ | |||
+ | - Open the mBlock app on your computer\\ \\ <WRAP round tip>You can download the mBlock app from [[https:// | ||
+ | - Click on the add button on the Devices tab\\ \\ <WRAP round tip>You can also click the ' | ||
+ | - Select the mBot and click the OK button\\ \\ <WRAP box>{{ : | ||
+ | - Click the Upload button under the Mode Switch section\\ \\ <WRAP round tip>This allows you to write your program without having the mBot connected to your computer</ | ||
+ | - Click the Events selector and drag the "when mBot(mCore) starts up" block to the coding pane\\ \\ <WRAP box>{{ : | ||
+ | - Click the Control selector and drag the "wait until < >" block to the coding pane and snap it to the bottom of the stack\\ \\ <WRAP box>{{ : | ||
+ | - Click the Sensing selector and drag the "when on-board button pressed?" | ||
+ | - Click the Control selector and drag the " | ||
+ | - Drag the "if < > then else" block to the coding pane and snap it inside the forever block\\ \\ <WRAP box>{{ : | ||
+ | - Click the Operators selector and drag the "( ) < 50" block to the coding pane and snap it into the if - then block\\ \\ <WRAP box>{{ : | ||
+ | - Click the Sensing selector and drag the " | ||
+ | - Change the " | ||
+ | - Click the Action selector and drag the "turn right at power 50% for 1 secs" block to the coding pane and snap it inside the top section of the if-then-else block\\ \\ <WRAP round tip>This will cause the mBot to turn right whenever it senses an obstacle within 10cm</ | ||
+ | - Change the " | ||
+ | - Drag the "move forward at power 50%" block to the coding pane and snap it inside the bottom section of the if-then-else block\\ \\ <WRAP round tip>This will cause the mBot to move forward whenever it does not sense an obstacle within 10cm</ | ||
+ | - Connect the USB cable to the mCore mainboard on the mBot and plug the cable into your computer | ||
+ | - Slide the power switch on the mCore mainboard on the mBot to the ON position and click the Connect button\\ \\ <WRAP box>{{ : | ||
+ | - Click the Upload button and wait for the upload to complete\\ \\ <WRAP box>{{ : | ||
+ | - Slide the power switch on the mCore mainboard on the mBot to the OFF position and disconnect the USB cable from the mBot | ||
+ | |||
+ | ===== Robot Testing ===== | ||
+ | |||
+ | Follow the steps below to test out the program you just created | ||
+ | |||
+ | - Place some of the styrofoam blocks on the floor | ||
+ | - Place the mBot on the floor and slide the power switch on the mCore mainboard on the mBot to the ON position | ||
+ | - Press the black button on the front left of the mCore mainboard on the mBot to start the mBot moving | ||
+ | - When you're finished watching the mBot avoid obstacles, pick it up and slide the power switch on the mCore mainboard to the OFF position | ||
+ | <WRAP round help> | ||
+ | <WRAP round tip>When you're ready to try out changes to your program, repeat steps 16 through 19 above</ | ||
+ | <WRAP round help>How could you change the program so that you can tell the mBot to stop moving instead of picking it up when you're done? Make that change and see if it works</ | ||
+ | <WRAP round help>How can you make the mBot start the obstacle avoidance using the infrared remote control like it did in [[: | ||
+ | |||
+ | [[: |