background image

8 | 

P a g e

 

 
 

Save the Project and Upload to the CyberPi 

 
Save the project to your computer by clicking on the 

File

 menu and choosing 

Save to your 

computer

.  

It is a good idea to create a folder to contain all your projects. 
 
Make sure you type in a descriptive name for your file. 
 

 
 
 
 
 

 

 

Содержание mBot2

Страница 1: ...1 P a g e Digital Technology MakeBlock mBot2 CyberPi Block Coding Version 1 0 Barry Butler Feb 2022 bbutl58 eq edu au...

Страница 2: ...tps www yuque com makeblock help center en mblock 5 CyberPi Blocks https www yuque com makeblock help center en cyberpi including Pocket Shield mBot2 Shield and mBuild Modules Firmware Update To updat...

Страница 3: ...tps www yuque com makeblock help center en mcode cyberpi api shields 9eo89 mBuild Modules Ultrasonic Sensor 2 Quad RGB Sensor https www yuque com makeblock help center en mcode cyberpi api mbuild or h...

Страница 4: ...he PC software seems to be more stable than the web version located at https python mblock cc 1 Run the MakeBlock software Mode switch File menu Rename project Coding space Connection button When you...

Страница 5: ...he ultrasonic sensor and the line follower sensor should turn on If they are don t the wiring is incorrect or unplugged and needs to be fixed 4 Select Upload mode 5 Plug the mBot2 into a USB port and...

Страница 6: ...6 P a g e 6 Click on the File menu and select New Project 7 Start coding...

Страница 7: ...to green for 2 seconds Click the Upload button to send your code to the mBot2 The code will start executing immediately it is uploaded Unsuccessful Upload If the upload is unsuccessful check three thi...

Страница 8: ...d to the CyberPi Save the project to your computer by clicking on the File menu and choosing Save to your computer It is a good idea to create a folder to contain all your projects Make sure you type...

Страница 9: ...has a joystick a home button and two push buttons A and B We can use the joystick and buttons in our code It also has a light sensor and microphone that we can use Instead of the code running automat...

Страница 10: ...nic sensor or colour sensors are used to control when the motors should stop Forward or backward for a length of time Forward or backward for a fixed distance Turn on the spot for a length of time whe...

Страница 11: ...m 1 Single Actions Use this when the mBot2 actions should only occur once If we have actions that are repeated we can use a for loop For example to move in a square CHALLENGES 1 Place one or more larg...

Страница 12: ...with the joystick and buttons or the ultrasonic and line follower sensors where the mBot2 will respond to changes in sensor values CHALLENGES 3 Place two small objects on the floor at least 1m apart D...

Страница 13: ...of it up to about 200cm It can be used to avoid obstacles or seek out an object and move toward it The minimum distance detected is about 4cm Smaller distances give a reading of 300 Test your Ultrason...

Страница 14: ...14 P a g e Slow Down when Close to a Collision Seek Objects and Move Toward Them Rotate to detect an object closer than 80cm then move toward the object...

Страница 15: ...5 Place 4 objects at the corners of a square Find one of them and stop before you hit it Turn and find the next object until you have found all four 6 Find your way autonomously through a simple maze...

Страница 16: ...us to detect and follow lines and detect colours and respond to the colours in different ways Test the Sensor using either of these by passing the mBot2 over a black line on a white background and ch...

Страница 17: ...reflected light value is less than 50 if we are on or near a black line Place the mBot2 on the middle of the black line If both sensors L1 and R1 are on black go straight ahead If only sensor L1 is on...

Страница 18: ...er between the left and right wheels How you interpret the percentage color sensor values Use the L2 and R2 sensors as well CHALLENGES 7 Oval Race Follow an oval line from start to finish Time the run...

Страница 19: ...alling off the edge H1 Basic Sumo Code The basic actions of a SumoBot are A three second wait before doing anything Move forward from the edge 20cm Rotate until the ultrasonic sensor locates the other...

Страница 20: ...bot lifted off the ground pitch or roll and respond to that see Appendix 1 If motion is stopped for x seconds use a series of rapid wheel movements e g back and forth to try and get free Use a differ...

Страница 21: ...r the general IO ports on the left S1 and S2 Read Analog Sensors Read analog sensors such as potentiometers or soil moisture sensors using ports S1 and S2 Read and Write Digital Sensors Run DC motors...

Страница 22: ...rint distance pot touch time sleep 0 1 Light sensor light cpi get_bri Sound sensor volume cpi get_loudness mode maximum Audio Commands cpi audio play_tone freq t cpi audio add_vol val 100 100 Accelero...

Отзывы: