mbotneo:lesson5
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
mbotneo:lesson5 [2024/02/16 15:04] – jstruebel | mbotneo:lesson5 [2024/03/29 09:52] (current) – jstruebel | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Objective ===== | ||
+ | This lesson will show you how to program the mBot Neo to recognize colors while following a line. It will then show you how test your program on the mBot Neo. | ||
+ | |||
+ | ===== Parts Required ===== | ||
+ | |||
+ | The parts below are required to complete this lesson. Note that all parts are included in the [[https:// | ||
+ | |||
+ | - Assembled mBot Neo from [[: | ||
+ | - USB Cable | ||
+ | - Line following paper | ||
+ | |||
+ | ===== Software Programming ===== | ||
+ | |||
+ | - Connect the USB cable to the CyberPi on the mBot Neo and plug the cable into your computer\\ \\ <WRAP round tip>This will charge up your mBot Neo while you create the program</ | ||
+ | - Open the mBlock app on your computer\\ \\ <WRAP round tip>You can download the mBlock app from [[https:// | ||
+ | - Click on the Extension button\\ \\ <WRAP box>{{ : | ||
+ | - Click the Add button under the mBot2 shield\\ \\ <WRAP box>{{ : | ||
+ | - Click on the Extension button\\ \\ <WRAP box>{{ : | ||
+ | - Click the Add button under the Quad RGB Sensor\\ \\ <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 Neo connected to your computer</ | ||
+ | - Click the Events selector and drag the "when CyberPi starts up" block to the coding pane\\ \\ <WRAP box>{{ : | ||
+ | - Click the Display selector and drag the "print makeblock and move to a newline" | ||
+ | - Change the " | ||
+ | - 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 " | ||
+ | - Change the " | ||
+ | - Click the Variables selector and click the Make a Variable button to create the following variables for all sprites\\ \\ <WRAP round tip>This will allow your program to store information that it needs and change it as it runs</ | ||
+ | - base_power\\ \\ <WRAP box>{{ : | ||
+ | - kp\\ \\ <WRAP box>{{ : | ||
+ | - left_power\\ \\ <WRAP box>{{ : | ||
+ | - right_power\\ \\ <WRAP box>{{ : | ||
+ | - Drag the "set base_power to 0" block to the coding pane and snap it to the bottom of the stack\\ \\ <WRAP box>{{ : | ||
+ | - Change the " | ||
+ | - Drag the "set base_power to 0" block to the coding pane and snap it to the bottom of the stack\\ \\ <WRAP box>{{ : | ||
+ | - Change the " | ||
+ | - Click the LED selector and drag the " | ||
+ | - Click the Control selector and drag the " | ||
+ | - Click the My Blocks selector and click the Make a Block button to create the following blocks\\ \\ <WRAP round tip>This will allow you to make your program neater</ | ||
+ | - follow_line\\ \\ <WRAP box>{{ : | ||
+ | - detect_colors\\ \\ <WRAP box>{{ : | ||
+ | - start_again\\ \\ <WRAP box>{{ : | ||
+ | - Drag the Define blocks in the coding pane to blank areas\\ \\ <WRAP box>{{ : | ||
+ | - Drag the " | ||
+ | - Drag the " | ||
+ | - Drag the " | ||
+ | - Click the Variables selector and drag the "set base_power to 0" block to the coding pane and snap it to the bottom of the Define follow_line block\\ \\ <WRAP box>{{ : | ||
+ | - Change the " | ||
+ | - Click the Operators selector and drag the "( ) - ( )" block to the coding pane and snap it into the "set left_power to 0" block\\ \\ <WRAP box>{{ : | ||
+ | - Drag the "( ) * ( )" block to the coding pane and snap it into the right side of the "set left_power to ( ) - ( )" block\\ \\ <WRAP box>{{ : | ||
+ | - Click the Variables selector and drag the " | ||
+ | - Drag the " | ||
+ | - Click the Quad RGB Sensor selector and drag the "quad rgb sensor 1 deviation (-100-100)" | ||
+ | - Click the Variables selector and drag the "set base_power to 0" block to the coding pane and snap it to the bottom of the Define line_following stack\\ \\ <WRAP box>{{ : | ||
+ | - Change the " | ||
+ | - Click the Operators selector and drag the "( ) * ( )" block to the coding pane and snap it into the "set right_power to 0" block\\ \\ <WRAP box>{{ : | ||
+ | - Drag the "( ) + ( )" block to the coding pane and snap it into the right side of the "set right_power to ( ) * ( )" block\\ \\ <WRAP box>{{ : | ||
+ | - Drag the "( ) * ( )" block to the coding pane and snap it into the right side of the "set right_power to ( ) * ( ( ) + ( ) )" block\\ \\ <WRAP box>{{ : | ||
+ | - Change the first of the "set right_power to ( ) * ( ( ) + ( ( ) * ( ) ) )" block to " | ||
+ | - Click the Variables selector and drag the " | ||
+ | - Drag the " | ||
+ | - Click the Quad RGB Sensor selector and drag the "quad rgb sensor 1 deviation (-100-100)" | ||
+ | - Click the mBot2 Chassis selector and drag the " | ||
+ | - Click the Variables selector and drag the " | ||
+ | - Drag the " | ||
+ | - Click the Control selector and drag the "if < > then" block to the coding pane and snap it to the bottom of the Define detect_colors block 4 times\\ \\ <WRAP box>{{ : | ||
+ | - Click the Quad RGB Sensor selector and drag the "quad rgb sensor 1 probe (1) R2 detects line?" block to the coding pane and snap it into each of the "if < > then" blocks\\ \\ <WRAP box>{{ : | ||
+ | - Change the "(1) R2" to " | ||
+ | - Change the "(1) R2" to " | ||
+ | - Change the "(1) R2" to " | ||
+ | - Change the "(1) R2" to " | ||
+ | - Click the Audio selector and drag the "play hi" block to the coding pane and snap it into each of the if - then blocks\\ \\ <WRAP box>{{ : | ||
+ | - Change the " | ||
+ | - Change the " | ||
+ | - Click the LED selector and drag the " | ||
+ | - Click on the LED colors in the top display block and change them all to " | ||
+ | - Click on the LED colors in the second display block and change them all to " | ||
+ | - Click on the LED colors in the third display block and change them all to " | ||
+ | - Click on the LED colors in the bottom display block and change them all to " | ||
+ | - Click the Variables selector and drag the "set base_power to 0" block to the coding pane and snap it into each of the if - then blocks\\ \\ <WRAP box>{{ : | ||
+ | - Change the " | ||
+ | - Change the " | ||
+ | - Change the " | ||
+ | - Click the Control selector and drag the "if < > then" block to the coding pane and snap it to the bottom of the Define start_again block\\ \\ <WRAP box>{{ : | ||
+ | - Click the Sensing selector and drag the " | ||
+ | - Change the " | ||
+ | - Click the Audio selector and drag the "play hi" block to the coding pane and snap it into the if - then block\\ \\ <WRAP box>{{ : | ||
+ | - Change the " | ||
+ | - Click the mBot2 Chassis selector and drag the "moves forward 100 cm until done" block to the coding pane and snap it into the if - then block\\ \\ <WRAP box>{{ : | ||
+ | - Change the " | ||
+ | - Click the LED selector and drag the " | ||
+ | - Click the Variables selector and drag the "set base_power to 0" block to the coding pane and snap it into the if - then block\\ \\ <WRAP box>{{ : | ||
+ | - Change the " | ||
+ | - Click the Events selector and drag the "when button A pressed" | ||
+ | - Click the Control selector and drag the " | ||
+ | - Change the name of the program in the upper left to " | ||
+ | - Slide the power switch on the mBot2 Shield to the ON position and click the Connect button\\ \\ <WRAP box>{{ : | ||
+ | - Click the Upload Code 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 Neo | ||
+ | |||
+ | ===== Robot Testing ===== | ||
+ | |||
+ | Follow the steps below to test out the program you just created | ||
+ | |||
+ | - Place the line following map on the floor | ||
+ | - Place the mBot on the line and slide the power switch on the mBot2 Shield on the mBot Neo to the ON position | ||
+ | - Press the B button on the CyberPi to start the mBot Neo moving | ||
+ | - When you're finished watching the mBot Neo follow the line, press the A button | ||
+ | - Change the sounds and LED colors to see how they change what the mBot Neo does | ||
+ | <WRAP round help> | ||
+ | <WRAP round tip>Try changing the LED display block with the LED animation block to see what it does</ | ||
+ | <WRAP round help> | ||
+ | <WRAP round tip>When you're ready to try out changes to your program, connect the USB cable to the CyberPi on the mBot Neo, plug the cable into your computer, and repeat steps 76 through 78 above</ | ||
+ | |||
+ | [[: |
mbotneo/lesson5.txt · Last modified: by jstruebel