Authorized Online Retailers

 

SKU:2020005200(with mainboard)

 

Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES ここでご購入を!

2020005300 (without mainboard)

Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES ここでご購入を!

In the previous course, we learned how to use an Android phone to control the car through Bluetooth. Here, we will learn how to use an IOS device to control the car.

The makecode programming code in this lesson is the same as that in the Android phone control lesson. Let’s learn how to start using the IOS Micro bit app first.


Bluetooth® is a wireless technology standard for exchanging data over short distances (using short-wavelength UHF radio waves in the ISM band from 2.4 to 2.485 GHz[3]) from fixed and mobile devices, and building personal area networks (PANs). We can use Bluettoth to connect multiple devices which resolves the difficulty of simultanuous data transmission.

Block

Analyse

Examples

From Bluetooth category

On Bluetooth Connected block starts an event handler which in this case will run when something connects to your micro:bit using Bluetooth.

From Bluetooth category

On Bluetooth Disconnected block starts an event handler which in this case will run when a device which is connected to your micro:bit over Bluetooth disconnects.

You could use this event handler to display a letter “D” on the micro:bit LED grid so you know that the Bluetooth connection has been closed.

From control category

Raise an event in the event bus.

From control category

Get the value of the last event executed on the bus.

From control category

Return a code representing the type of the event (button click, device gesture, and so on).

The micro:bit app is the essential companion to the BBC micro:bit, the pocket sized programmable computer. The app provides online access to a choice of code editors for programming your micro:bit and, when your program is ready, the app beams it to the micro:bit via Bluetooth wireless. Easy-to-follow screens lead you through the process of pairing your iPad (or iPhone) to the micro:bit and then transferring your program code.

In this lesson we will use the GamePad function in the app Monitor and Control interface.About pair micro:bit mainbaord with the app,please learnning lesson 3.

Note:

1.If you are using a new micro:bit for the first time and pair the device unsuccessfully, please connect the micro:bit to a computer with a USB cable
and downloading the ‘Start-up’ hex file from here: www.osoyoo.com/picture/Microbit_Robot/Guide-to-mobile&tablet-apps/microbit-pair-ios.hex.

2. To Learn more troubleshoot of pairing, please visit the link: https://www.microbit.org/get-started/user-guide/ble-ios/

APP Download

Control the Robot Car via Bluetooth

Step 1)Open the APP, then TAP the Monitor and Control on the APP interface.

Step 2)Tap the Add and then select the Gamepad.

Step 3)You should see the control interface shown below. Click Start to connect.

Step 4) Please confirm that the Micro:bit mainboard is always connected to Bluetooth

Step 5)Connection successful! “Smile” is displayed on Bluetooth connection, and “X” is displayed on Bluetooth disconnection.(You can click Stop to disconnect.)

Step 0: Go to urlhttps://makecode.microbit.org, click New Project

Step 1: To connect with micro:bit, we should first pair then connect, Click the icon on the top right: More… ->Project Setting,

Step 2: check the first option “No Pairing Required: Anyone can connect via Bluetooth”

Step 3. In the Editor controls, click on the Advanced button and then Extensions  as following figure.

Step 4. In the Extensions page , you can see the Bluetooth package and click it to add the package, you will see a  pop up window, and click “Remove extensions and add bluetooth. (Note: If you don’t see the bluetooth package the first of Extensions page, please enter “bluetooth” in search textbox and then search it.)

Step 5. Please remove the on start and forever block. Click on the Bluetooth category and then click the on bluetooth connected block as following:

Step 6. Click on the Basic category, then drag the show icon block and drop it inside the on bluetooth connected block ,and choose the icon from the drop-down menu as following figure.

Step 7. Click on the Bluetooth category again and then click the on bluetooth disconnected block as following:

Step 8. Duplicate the show icon block and drop it inside the on bluetooth disconnected block ,and choose the icon from the drop-down menu as following figure.

Step 9. In the Editor controls, click on the Advanced button and then Control as following:

Step 10. Click on the Control category, then drag the on event from block and choose MES_DPAD_CONTROLLER_ID and MICROBIT_EVT_ANY from the drop-down menu as following figure.

Step 11. Click on the Logic category and then click the if then else block, and then Drag inside on event from block as following:

Step 12. Click on the Logic category again. Under the Comparison section, drag “0 = 0” blocks over, and place it on the placeholder of the if-then-else block as following:

Step 13. Click on the Control category and drag and drop the event value block and place it on the first placeholder of the Comparison block

Step 14. Click on the Control category then more, and drag and drop the MICROBIT_EVT_ANY block and place it on the second placeholder of the Comparison block, then select MES_DPAD_BUTTON_A_DOWN.

Step 15. Enter Extensions page , enter project URL “https://github.com/osoyoo/OSOYOO-MICRO-BIT-CAR ” in the Search textbox and click on the Search button. The page will show you all the matching extensions based on your search string. Now, click on osoyoo to add it into your project .

Step 16. Click OSOYOO_Robot category, and Drag and drop CarCtrl block over and place it inside the “then” section of the if-then-else block, and change the direction to forward.

Step 17. Click “+” to add an else section as following:

Step 18. Duplicate Comparison block and change MES_DPAD_BUTTON_A_DOWN to MES_DPAD_BUTTON_A_up, and then place it on the second if section as following picture:

Step 19. Duplicate CarCtrl block and change the direction to Stop, and then place it on the second then section as following picture:

Step 20. Click “+” to add an else section, and duplicate Comparison block and change MES_DPAD_BUTTON_A_up to MES_DPAD_BUTTON_B_down, and then place it on the third if section as following picture:

Step 21. Duplicate CarCtrl block and change the direction to Back, and then place it on the third then section as following picture:

Step 22. Click “+” to add an else section, and duplicate Comparison block and change MES_DPAD_BUTTON_B_Down to MES_DPAD_BUTTON_B_up, and then place it on the fourth if section as following picture:

Step 23. Duplicate CarCtrl block and change the direction to stop, and then place it on the fourth then section as following picture:

Step 24. Click “+” to add an else section, and duplicate Comparison block and change MES_DPAD_BUTTON_B_up to MES_DPAD_BUTTON_C_down, and then place it on the fifth if section as following picture:

Step 25. Duplicate CarCtrl block and change the direction to Turn left, and then place it on the fifth then section as following picture:

Step 26. Click “+” to add an else section, and duplicate Comparison block and change MES_DPAD_BUTTON_C_Down to MES_DPAD_BUTTON_C_up, and then place it on the sixth if section as following picture:

Step 27. Duplicate CarCtrl block and change the direction to stop, and then place it on the sixth then section as following picture:

Step 28. Click “+” to add an else section, and duplicate Comparison block and change MES_DPAD_BUTTON_C_up to MES_DPAD_BUTTON_D_down, and then place it on the seventh if section as following picture:

Step 29. Duplicate CarCtrl block and change the direction to Turn right, and then place it on the seventh then section as following picture:

Step 30. Click “+” to add an else section, and duplicate Comparison block and change MES_DPAD_BUTTON_D_Down to MES_DPAD_BUTTON_D_up, and then place it on the eighth if section as following picture:

Step 31. Duplicate CarCtrl block and change the direction to stop, and then place it on the eighth then section as following picture:

Step 32. Click “+” to add an else section, and duplicate Comparison block and change MES_DPAD_BUTTON_D_up to MES_DPAD_BUTTON_1_down, and then place it on the ninth if section as following picture:

Step 33. Click on the OSOYOO_Robot category. Drag RGB Car Big2 value off  block and place it inside the ninth then section, set white (as you like) from drop-down menu.

Step 34. Click “+” to add an else section, and duplicate Comparison block and change MES_DPAD_BUTTON_1_Down to MES_DPAD_BUTTON_1_up, and then place it on the tenth if section as following picture:

Step 35. Duplicate RGB Car Big2 value block and change the color to off, and then place it on the tenth then section as following picture:

Step 36. Click “+” to add an else section, and duplicate Comparison block and change MES_DPAD_BUTTON_1_up to MES_DPAD_BUTTON_2_down, and then place it on the eleventh if section as following picture:

Step 37. Duplicate RGB Car Big2 value block and change the color to blue, and then place it on the eleventh then section as following picture:

Step 38. Click “+” to add an else section, and duplicate Comparison block and change MES_DPAD_BUTTON_2_Down to MES_DPAD_BUTTON_2_up, and then place it on the twelfth if section as following picture:

Step 39. Duplicate RGB Car Big2 value block and change the color to off, and then place it on the twelfth then section as following picture:

Step 40. Click “+” to add an else section, and duplicate Comparison block and change MES_DPAD_BUTTON_2_up to MES_DPAD_BUTTON_3_down, and then place it on the thirteenth if section as following picture:

Step 41. Duplicate RGB Car Big2 value block and change the color to green, and then place it on the thirteenth then section as following picture:

Step 42. Click “+” to add an else section, and duplicate Comparison block and change MES_DPAD_BUTTON_3_Down to MES_DPAD_BUTTON_3_up, and then place it on the fourteenth if section as following picture:

Step 43. Duplicate RGB Car Big2 value block and change the color to off, and then place it on the fourteenth then section as following picture:

Step 44. Click “+” to add an else section, and duplicate Comparison block and change MES_DPAD_BUTTON_3_up to MES_DPAD_BUTTON_4_down, and then place it on the fifteenth if section as following picture:

Step 45. Click on the Music category. Then  drag the Play tone for beat block over, and drop it on the fifteenth then section. and select Middle C as tone, 1/2 as beat

Step 46. Click “-” to remove an else section, and the whole code as following:

Step 47. Rename this project and download the hex file as following

 

Step A)Connect the micro:bit with the computer through USB cable, and the computer will pop up a U disk and send the download file(.hex)to your micro:bit.

Step B)Insert the micro:bit main board into the robot, and connect a 9v battery into the battery box.

Step C)Turn the POWER switch ON.

Click A,the robot runs forward

Click B,the robot  runs backwards

Click C,the robot runs turn left

Click D,the robot runs turn right

Click 1,the robot RGB  headlights shows white color

Click 2,the robot RGB  headlights shows blue color

Click 3,the robot RGB  headlights shows green color

Click 4,the robot buzzer sounds.