background image

169

www.keyestudio.com

Project 10: Touch-sensitive Logo

(1)Project Description

The Micro: Bit main board V2 is equipped with a golden touch-sensitive

logo, which can act as an input component and function like an extra

button.

It contains a capacitive touch sensor that senses small changes in the

electric field when pressed (or touched), just like your phone or tablet

screen do.When you press it , you can activate the program.

(2)Experimental Preparation:

Connect micro:bit to computer with the USB cable

Open online Makecode editor

Import Hex profile (How to import?)

Or click“New Project”and drag blocks step by step

(3)Test Code

Summary of Contents for 4WD Bluetooth Multi-functional Car

Page 1: ...1 www keyestudio com Keyestudio 4WD Mecanum Robot Car Makecode Contents 1 Introduction 4 2 Description 6 3 Parameters 6 4 Kit List 7 5 Preparations 12...

Page 2: ...mation about Keyestudio 4WD Mecanum Robot Car 18 6 2 the Installation of keyestudio 4WD Mecanum Robot Car 20 7 Get Started with Micro bit 42 7 1 Write code and program 42 7 2 Makecode 53 7 3 Quick Dow...

Page 3: ...Communication 187 Project 13 Colorful Lights 208 Project 14 WS2812 RGB LEDs 215 Project 15 Servo 238 Project 16 Motor 247 Project 17 Line Tracking Sensor 260 17 1 Detect Line Tracking Sensor 260 17 2...

Page 4: ...simple graphical programming platforms from micro bit to Arduino and Raspberry Pi Maybe you haven t heard of them before It doesn t matter because with the help of this product and tutorial you can ea...

Page 5: ...can not only experience the fun of creation but enhance hands on ability and learn programming skills as well MakeCode for micro bit is the most widely used graphical programming environment on the mi...

Page 6: ...When installing and disassembling the battery please pay attention to the positive and negative poles of the battery and be sure not to reverse the them By the way the motor speed of this product is a...

Page 7: ...of micro bit is 3 3V driver shield integrates 3 3V 5V communication conversion circuit 4 Kit List Picture Components Quanti ty 1 KS0511 Acrylic Board T 3mm 1 2 Acrylic Board with Lego Holes T 3mm 1 3...

Page 8: ...tudio com 5 Servo 1 6 Mecanum Wheels 4 7 Keyestudio Micro bit IO Port Expansion Sensor Shield With Level Conversion 1 8 Micro bit Main Board V2 0 with Package for KS4031 1 Micro bit Main Board V2 0 fo...

Page 9: ...9 www keyestudio com 9 Keyestudio Driver Board 1 10 M3 20MM Dual pass Copper Pillar 4 11 4265c Lego Part 4 12 43093 Lego Part 4 13 Acrylic Gasket Six in One Pack 1...

Page 10: ...10 www keyestudio com 14 M3 6MM Round Head Screw 18 15 Keyestudio Ultrasonic Module 1 16 M3 Nickle plated Nut 14 17 M3 30MM Round Head Screw 9 18 M2 Nickle plated Nut 3 19 M2 8MM Round Head Screw 3...

Page 11: ...Round Head Screw 5 21 Remote Control without batteries 1 22 Plastic String 3 100mm 5 23 USB Cable 1 24 HX 2 54 2P DuPont Wire 100mm 1 25 HX 2 54 4P DuPont Wire 50mm 2 26 XH2 54 4P DuPont Wire 160mm 1...

Page 12: ...ons The core device is a 32 bit Arm Cortex M4 with FPU micro processing Though it is just the size of a credit card the Micro bit main board is equipped with loads of components including a 5 5 LED do...

Page 13: ...t also supports a variety of codes and graphical programming platforms and is compatible with almost all PCs and mobile devices It has no need to install drivers It is of high integration of electroni...

Page 14: ...nformation please resort to following links https tech microbit org hardware https microbit org new microbit https www microbit org get started user guide overview https microbit org get started user...

Page 15: ...P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 P19 P20 ADC DAC P0 P1 P2 P3 P4 P10 IIC P19 SCL P20 SDA SPI P13 SCK P14 MISO P15 MOSI PWM used frequently P0 P1 P2 P3 P4 P10 PWM not frequently u...

Page 16: ...ponents b Its IO port is very weak in driving since it can merely handle current less than 300mA Therefore do not connect it with devices operating in large current such as servo MG995 and DC motor or...

Page 17: ...ed with battery more than 3 3V or the main board will be damaged g Forbid to operate it on metal products to avoid short circuit To put it simple Micro bit V2 main board is like a microcomputer which...

Page 18: ...integrated into the bottom plate an ultrasonic sensor servos 2 colorful lights 4 WS2812 RGB lights The wiring is not complicated and it has Lego jacks to facilitate connection with other peripheral d...

Page 19: ...B lights and infrared receiver servo are integrated in the base Pins Pin on Micro bit Sensors of the keyestudio 4WD Mecanum Robot Car P1 P2 Line Tracking Sensor P14 Servo P8 4 WS2812RGB Lights P9 Infr...

Page 20: ...20 www keyestudio com charger to charge the 18650 lithium battery Please note This product does not contain batteries 6 2 the Installation of keyestudio 4WD Mecanum Robot Car Part 1 Components Needed...

Page 21: ...21 www keyestudio com Installation Diagram Prototype Part 2...

Page 22: ...22 www keyestudio com Components Needed Installation Diagram...

Page 23: ...23 www keyestudio com Prototype Part 3...

Page 24: ...24 www keyestudio com Components Needed Installation Diagram...

Page 25: ...25 www keyestudio com Prototype Part 4 adjust the angle of the servo first Adjust the angle of the servo to 90 degrees according to the test code in project 8 15...

Page 26: ...26 www keyestudio com Components Needed Installation Diagram mind the installation direction...

Page 27: ...27 www keyestudio com Prototype Part 5 Components Needed...

Page 28: ...28 www keyestudio com Installation Diagram Prototype Part 6...

Page 29: ...29 www keyestudio com Components Needed Installation Diagram...

Page 30: ...30 www keyestudio com Prototype Part 7 Components Needed...

Page 31: ...31 www keyestudio com Installation Diagram mind the direction of the motor Prototype Part 8...

Page 32: ...32 www keyestudio com Components Needed Installation Diagram Pay attention to the installation direction of the mecanum wheel...

Page 33: ...33 www keyestudio com Prototype Part 9 Components Needed...

Page 34: ...34 www keyestudio com Installation Diagram Prototype Part 10...

Page 35: ...35 www keyestudio com Components Needed Installation Diagram...

Page 36: ...36 www keyestudio com Prototype Start Wiring The wiring of the RGB lights...

Page 37: ...37 www keyestudio com The wiring of the infrared receiver module The wiring of the motor and colorful lights...

Page 38: ...38 www keyestudio com The wiring of the line tracking sensor The wiring of the ultrasonic sensor...

Page 39: ...39 www keyestudio com The wiring of the servo The wiring of the M1 motor...

Page 40: ...40 www keyestudio com The wiring of the M2 motor The wiring of the M3 motor...

Page 41: ...41 www keyestudio com The wiring of the M4 motor The wiring of the power supply the 5V is connected to the shield...

Page 42: ...ded to browse the official website of Micro bit for more details and the link is attached below https microbit org guide quick Step 1 connect the Micro Bit main board with your computer Firstly link t...

Page 43: ...ed When your computer communicates with the main board via the USB cable the yellow LED on it will flashes For example it will flicker when you burn a hex file Then Micro bit main board will appear on...

Page 44: ...roject appears fill it with heartbeat and click Create to edit If you are running Windows 10 system it is also viable to edit on the APP MakeCode for micro bit which is exactly like editing in the web...

Page 45: ...45 www keyestudio com...

Page 46: ...nd then run your program in Simulator of MakeCode editor as shown in the picture below which demonstrates how to edit heartbeat program Click the arrow behind JS JavaScript to choose between JavaScrip...

Page 47: ...47 www keyestudio com...

Page 48: ...nload the program to your Micro Bit main board is merely clicking the Download button then all is done If you are writing program through the website following these steps Click the Download in the ed...

Page 49: ...ww keyestudio com process that you copy the file to the USB driver If you are running Windows system you can also right click and select Send to MICROBIT E to copy the hex file to the Micro Bit main b...

Page 50: ...50 www keyestudio com You can also directly drag the hex file onto the MICROBIT E disk...

Page 51: ...side of the board flashes When the copy is completed the yellow signal light will stop flashing and remain on Step 4 run the program After the program is uploaded to the Micro bit main board you coul...

Page 52: ...ss to hexadecimal files hex and save no other files Step 5 about other programming languages This chapter has described how to use the Micro bit main board But except for the Makecode graphical progra...

Page 53: ...Makecode Browse https makecode microbit org and enter Makecode online editor or open the APP MakeCode for micro bit of Windows 10 Click New Project and input heartbeat then click create to enter Makec...

Page 54: ...means that the code in the block only executes once while forever implies that the code runs cyclically 7 3 Quick Download As mentioned before if your computer is Windows 10 and you have downloaded t...

Page 55: ...ode However if you use Google Chrome suitable for Linux macOS and Windows 10 the process can be quicker too We use the webUSB function of Chrome to allow the internet page to access the hardware devic...

Page 56: ...56 www keyestudio com Click Next...

Page 57: ...57 www keyestudio com Click another Next...

Page 58: ...or selection please refer to https makecode microbit org device usb webusb troubleshoot And for updating the firmware of the Micro bit https microbit org guide firmware If the links are too troublesom...

Page 59: ...59 www keyestudio com in the folder we provided in the link https fs keyestudio com KS4031 4032 Click Done to finish the pairing...

Page 60: ...60 www keyestudio com...

Page 61: ...61 www keyestudio com Download program After the pairing click download to directly download the program to the board If it is successfully downloaded the icon will shift to...

Page 62: ...io com 7 4 Makecode extension library For your convenience we have made a makecode extension library for this smart home kit Add smart home extension library Please follow the following steps to add e...

Page 63: ...63 www keyestudio com Open Makecode to enter a certain project click the gear shaped icon for setting in the upper right corner choose Extensions Or click Advanced to select Extensions as shown below...

Page 64: ...64 www keyestudio com Input the link https github com keyestudio2019 ks_IoT to search Tap the searching result IoT_keyestudio to download and install it This process may take a few seconds...

Page 65: ...65 www keyestudio com After the installation you can find the extension files DHT11 DHT22 and I2C_LCD1602 on the left side And extension file Neopixel is also installed...

Page 66: ...66 www keyestudio com...

Page 67: ...67 www keyestudio com...

Page 68: ...roject Therefore when you create a new IoT_keyestudio project you will need to add these extension files again Update or delete the IoT_keyestudio extension files Please follow the following steps to...

Page 69: ...69 www keyestudio com Click the Explorer on the left side...

Page 70: ...eyestudio com You can find these added files in the list Click the dustbin icon beside the file to delete the corresponding file Tap the refresh icon to update the corresponding IoT_keyestudio extensi...

Page 71: ...urces and test code We also provide a link https fs keyestudio com KS4031 4032 containing the information of the product from relevant tools to test codes tutorials and troubleshooting methods as well...

Page 72: ...rag the code blocks to complete the program for each project For simple projects dragging a block of code to complete the program is recommended For complex projects it is recommended to conduct the p...

Page 73: ...73 www keyestudio com Click Import File...

Page 74: ...74 www keyestudio com Select Makecode Code Project 1_ Heart beat Project 1_ Heart beat hex Then click Go ahead...

Page 75: ...o importing the test code file provided into the Makecode compiler above you can also drag the the test code file provided into the code editing area of the Makecode compiler as shown in the figure be...

Page 76: ...ome Therefore digital signal or analog signal of sensors and modules cannot be shown on the serial port simulator However you need to read the corresponding digital signal or analog signal So what can...

Page 77: ...erial port Download CoolTerm program https freeware the meiers org After the download we need to install CoolTerm program file below is PC Window system taken as an example 1 Choose win to download th...

Page 78: ...www keyestudio com 3 Double click please make sure that the driver of Micro bit is installed and the main board is connected with the computer The functions of each button on the Toolbar are listed be...

Page 79: ...dot matrix of the Micro bit main board V2 Open up a new Terminal Open a saved Connection Save the current Connection to disk Open the Serial Connection Close the Serial Connection Clear the Received D...

Page 80: ...display a relatively big heart shaped pattern and then a smaller one This alternative change of this pattern is like heart beating This experiment serves as a starter for your entry to the programming...

Page 81: ...load File Type Path File Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project Code Project 1 Heartbeat Project 1 Heartbeat hex Or you could edit code step by step in the editing ar...

Page 82: ...select Complete Program on start command block runs once to start program The program under the block forever runs cyclically LED dot matrix displays LED dot matrix shows Click JavaScript to view the...

Page 83: ...ry again Project 2 Light A Single LED 1 Project Description The LED dot matrix consists of 25 LEDs arranged in a 5 by 5 square In order to locate these LEDs quickly as the figure shown below we can re...

Page 84: ...Open online Makecode editor Import Hex profile How to import Or click New Project and drag blocks step by step 3 Test Code The route to get test code How to load File Type Path File Name Hex file KS40...

Page 85: ...ep in the editing area A Click Led more led enable false B Put it into the on start block and click the drop down triangle button to select true 2 A Enter Led toggle x 0 y 0 block B Combine it with fo...

Page 86: ...dio com B Then move it below the toggle x1 y0 block and set to 500ms 4 Duplicate code string once and place it into forever block A Enter Led plot x 0 y 0 B Keep it beneath block pause ms 500 then set...

Page 87: ...4 Replicate pause ms 500 once and keep it below the block plot x3y4 Click Led unplot x 0 y 0 and set to unplot x3 y 4 Lay down it beneath pause ms 500 block Copy pause ms 500 block once and keep it be...

Page 88: ...88 www keyestudio com block...

Page 89: ...lock only runs once to start program Turn on LED dot matrix The program under the block forever runs cyclically Toggle the LED brightness at coordinate point x 1 y 0 Toggle the LED brightness at coord...

Page 90: ...oading test code to micro bit main board V2 and powering the main board via the USB cable the LED in 1 0 lights up for 0 5s and the one in 3 4 shines for 0 5s and repeat this sequence How to download...

Page 91: ...rtain LED to light by integrating its position value into the test code Supported by the same theory we can turn on many LEDs at the same time to showcase patterns digits and characters What s more we...

Page 92: ...rix 1 Project 3 LED Dot Matrix 1 Or you could edit code step by step in the editing area A Enter Led more led enable false Click the drop down triangle button to select true Combine it with on start b...

Page 93: ...93 www keyestudio com Complete Program...

Page 94: ...Python language code Code 2 on start command block only runs once to start program Turn on LED dot matrix The program under the block forever runs cyclically Toggle the LED brightness at coordinate p...

Page 95: ...der Makecode Tutorial Makecode Code Project Code Project 3 LED Dot Matrix 2 Project 3 LED Dot Matrix 2 Or you could edit code step by step in the editing area A Enter Basic show number 0 block Duplica...

Page 96: ...it into forever block tick blue boxes to light LED and generate pattern 1 Move out the block show string from Basic block and leave it beneath the show leds block Choose show icon from Basic block an...

Page 97: ...97 www keyestudio com 2 A Enter Basic show arrow North B Leave it into forever block replicate show arrow North for 3 times respectively set to North East South East South West North West...

Page 98: ...98 www keyestudio com 3 Click Basic to get block clear screen then remain it below the block show arrow North West 5 Drag pause ms 100 block from Basic block and set to 500ms then...

Page 99: ...99 www keyestudio com leave it below clear screen block Complete Program...

Page 100: ...r program runs cyclically Dot matrix shows the pattern Dot matrix scrolls to show Hello is shown on dot matrix LED dot matrix displays North East arrow The South East arrow shows up on LED dot matrix...

Page 101: ...101 www keyestudio com Select JavaScript and Python to switch into JavaScript and Python language code 4 Test Results Upload code 1 and power the board we will see the icon...

Page 102: ...and patterns How to download How to quick download Project 4 Programmable Buttons 1 Project Description Buttons can be used to control circuits In an integrated circuit with a push button the circuit...

Page 103: ...m together and the LED dot matrix shows A B and AB respectively Let s get started 2 Experimental Preparation Connect micro bit to computer with the USB cable Open online Makecode editor Import Hex pro...

Page 104: ...Programmable Buttons 1 Or you could edit code step by step in the editing area 1 Delete on start and forever firstly then click Input on button A pressed 1 A Click Basic show string B Then place it in...

Page 105: ...105 www keyestudio com B 3 Copy once and set to on button A B pressed and show string AB Complete Code...

Page 106: ...Python to switch into JavaScript and Python language code Code 2 Press button A on Micro bit main board Show the character A Press button B on Micro bit main board Show the character B Press button A...

Page 107: ...Buttons 2 Project 4 Programmable Buttons 2 Or you could edit code step by step in the editing area A Click Led more led enable false B Put it into the block on start click drop down triangle button t...

Page 108: ...tton A pressed B Go to Variables change item by 1 C Place it into on button A pressed and 1 is modified into 5 Duplicate code string once click the drop down button to select B then set change item by...

Page 109: ...e item into 0 box change 0 into 25 A Go to Logic to move out if true then and blocks B Keep into true box and set to C Select item in the Variables and lay it down at left box of change 0 into 25 D En...

Page 110: ...110 www keyestudio com 7 A Replicate code string once B is modified into and 25 is changed into 0 C Leave it beneath code string Complete Program...

Page 111: ...on Micro bit board Change item by 5 Press button B on Micro bit board Change item by 5 The program under the block forever runs cyclically Light on LED in dot matric to draw bar graph light up up to...

Page 112: ...he 5 5 LED dot matrix shows A if button A is pressed B if button B pressed and AB if button A and B pressed together After uploading test code 2 to micro bit main board V2 and powering the main board...

Page 113: ...ut uses the temperature sensor built into NFR52833 chip for temperature detection Therefore the detected temperature is more closer to the temperature of the chip and there maybe deviation from the am...

Page 114: ...emperature The route to get test code How to load File Type Path File Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project Code Project 5 Temperature Measurement 1 Project 5 Temper...

Page 115: ...ck Serial to drag out serial write value x 0 Move it into forever block Go to Input temperature Place it into 0 box Change x into Temperature Move pause ms 100 from Basic block and place it under bloc...

Page 116: ...116 www keyestudio com Complete Program...

Page 117: ...n start command block runs once to start program Serial redirect to USB The program under the block forever runs cyclically Serial writes Temperature Delay in 500ms Click JavaScript to view the corres...

Page 118: ...118 www keyestudio com Download code 1 to micro bit board and keep USB cable connected then tap button How to quick download Temperature data is shown below...

Page 119: ...the temperature rises to 37 when it touches water cup Open CoolTerm click Options to select SerialPort Set COM port and 115200 baud rate the baud rate of USB serial communication of Micro bit is 1152...

Page 120: ...120 www keyestudio com...

Page 121: ...121 www keyestudio com...

Page 122: ...122 www keyestudio com...

Page 123: ...123 www keyestudio com Code 2 Micro bit display different pictures by temperature the temperature value in the code could be adjusted The route to get test code How to load File Type Path File Name...

Page 124: ...5 Temperature Measurement 2 Or you could edit code step by step in the editing area You could set temperature based on real situation Click Led more led enable false into on start click drop down tri...

Page 125: ...A Change into B Go to Input temperature and move it into left 0 box C Change 0 into 35 Tap Basic show icon copy it once and lay down them under the if then and else blocks then click the drop down tri...

Page 126: ...ng JavaScript code is shown below on start command block runs once to start program Turn on LED dot matrix Under the block forever program runs cyclically If the detected temperature 35 the next progr...

Page 127: ...emperature is less than 35 5 5LED will show When the temperature is equivalent to or greater than 35 the pattern will appear How to download How to quick download Project 6 Geomagnetic Sensor 1 Projec...

Page 128: ...y it to determine the location We need to calibrate the Micro bit board when magnetic sensor works The correct calibration method is to rotate the Micro bit board In addition the objects nearby may af...

Page 129: ...omagnetic Sensor 1 Project 6 Geomagnetic Sensor 1 Or you could edit code step by step in the editing area A Click Input more calibrate compass B Lay down it into block on start A Go to Input on button...

Page 130: ...tton A is pressed LED dot matrix indicates that TILT TO FILL SCREEN then enter the calibration interface The calibration method rotate the micro bit to make LED dot matrix draw a square 25 LEDs are on...

Page 131: ...ished until you view the smile pattern appear The serial monitor will show 0 90 180 and 270 when pressing A Code 2 Make micro bit board point to the north south east and west horizontally LED dot matr...

Page 132: ...ex file KS4031 4032 folder Makecode Tutorial Makecode Code Project Code Project 6 Geomagnetic Sensor 2 Project 6 Geomagnetic Sensor 2 This module can keep reading data to determine direction so does p...

Page 133: ...right when the value ranges from 292 5 to 337 5 Because 0 5 can t be input in the code the values we get are 293 and 338 Link computer with micro bit board by micro USB cable and program in MakeCode e...

Page 134: ...ver block A Go to Input compass heading and keep it into 0 box Tap Logic if then else leave it below block sex x to compass heading then click icon for 6 times A Place and into true block B Then move...

Page 135: ...135 www keyestudio com A Go to Basic show leds B Lay it down beneath block then click show leds and the pattern appears...

Page 136: ...136 www keyestudio com A Duplicate for 6 times B Separately leave them into the blank boxes behind else if C Set to x 23 and x 68 x 68 and x 113 x 113 and x 158...

Page 137: ...com x 158 and x 203 x 203 and x 248 x 248 and x 293 respectively D Then copy show leds for 7 times and keep them below the else if then block respectively E Click the blue boxes to form the pattern an...

Page 138: ...y Store the angle of the compass heading into the variable x When 293 x 338 the next program will be executed appears on the dot matrix When 23 x 68 the next program will be executed is displayed on d...

Page 139: ...ge code When 158 x 203 the next program will be executed Dot matrix shows When 203 x 248 the next program will be executed Dot matrix displays When 248 x 293 the next program will be executed Dot matr...

Page 140: ...140 www keyestudio com...

Page 141: ...ww keyestudio com 4 Test Results Upload code 2 and plug micro bit into power After calibration tilt micro bit board and the LED dot matrix displays the direction signs How to download How to quick dow...

Page 142: ...the accelerometer only detects the gravitational acceleration when the Micro bit is slightly shaken the acceleration detected is much smaller than the gravitational acceleration and can be ignored Th...

Page 143: ...ute to get test code How to load File Type Path File Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project Code Project 7 Accelerometer 1 Project 7 Accelerometer 1 Or you could edit...

Page 144: ...into 1 2 A Copy code string for 7 times separately click the triangle button to select logo up logo down screen up screen down tilt left tilt right and free fall then respectively change 1 into 2 3 4...

Page 145: ...145 www keyestudio com Shake the Micro bit board LED dot matrix displays 1 The log is up LED dot matrix displays 2 The logo is down LED dot matrix displays 3 The screen is up LED dot matrix displays 4...

Page 146: ...he corresponding JavaScript code The screen is down Number 5 is shown The Micro bit board is tilt to the left Number 6 is displayed The Micro bit board is tilt to the right Number7 is displayed When t...

Page 147: ...he value of acceleration speed at x y and z axis The route to get test code How to load File Type Path File Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project Code Project 7 Acce...

Page 148: ...o to Advanced Serial serial redirect to USB B Drag it into on start A Enter Serial serial write value x 0 B Leave it into forever block A Click Input acceleration mg x B Keep it into 0 box and capital...

Page 149: ...149 www keyestudio com Replicate code string for 3 times and keep them into forever block separately set the whole code string as follows...

Page 150: ...icro bit board keep USB cable connected and on start command block runs once to start program Serial redirects to USB The program under the block forever runs cyclically Serial write value X accelerat...

Page 151: ...ck How to quick download After referring to the MMA8653FC data manual and the hardware schematic diagram of the Micro Bit main board V2 the accelerometer coordinate of the Micro Bit V2 motherboard are...

Page 152: ...udio com The following interface shows the decomposition value of acceleration in X axis Y axis and Z axis respectively as well as acceleration synthesis acceleration synthesis of gravity and other ex...

Page 153: ...indows 10 via Google Chrome won t be able to match devices You ll need to use the CoolTerm serial monitor software to read data You could open CoolTerm software click Options select SerialPort set COM...

Page 154: ...shows the data of X axis Y axis and Z axis as shown in the figures below 4 Test Results After uploading the test code 1 to micro bit main board V2 and powering the board via the USB cable if we shake...

Page 155: ...t is kept upside down make its logo below the LED dot matrix it shows as below When it is placed still on the desk showing its front side the number 4 appears When it is placed still on the desk showi...

Page 156: ...w When the board is knocked to the floor this process can be considered as a free fall and the LED dot matrix shows the number 8 please note that this test is not recommended for it may damage the mai...

Page 157: ...nce the main board is not equipped with a photoresistor When the light irradiates the LED matrix the voltage change will be produced Therefore we could determine the light intensity by voltage change...

Page 158: ...ode Project 8 Light Detection Project 8 Light Detection Or you could edit code step by step in the editing area 1 A Enter Advanced Serial serial redirect to USB B Drag it into on start block 2 A Go to...

Page 159: ...159 www keyestudio com A Click Basic pause ms 100 B Lay it down into forever and set to 100ms Complete Program...

Page 160: ...d block runs once to start program Serial redirects to USB The program under the block forever runs cyclically Serial write value Light intensity light level Delay in 100ms Click JavaScript to switch...

Page 161: ...on t plug off USB cable and click How to quick download The intensity value is 0 when covering LED dot matrix And the value varies with the light intensity When placing micro bit under the sunlight th...

Page 162: ...oolTerm click Options to select SerialPort and set COM port and 115200 baud rate the baud rate of USB serial communication of micro bit is 115200 through the test Then click OK and Connect The light i...

Page 163: ...163 www keyestudio com Project 9 Speaker...

Page 164: ...e playing the son Ode to Joy 2 Experimental Preparation Connect micro bit to computer with the USB cable Open online Makecode editor Import Hex profile How to import Or click New Project and drag bloc...

Page 165: ...to find show icon and drag it into on start block Click the little triangle to find 2 Enter Music module to find and drug play sound giggle until done into forever block Enter Basic module to find an...

Page 166: ...166 www keyestudio com forever block Click the little triangle to select happy hello yawn...

Page 167: ...167 www keyestudio com Complete Program Select JavaScript and Python to switch into JavaScript and Python language code...

Page 168: ...4 Test Results After uploading the test code to micro bit main board V2 and powering the board via the USB cable the speaker utters sound and the LED dot matrix shows the logo of music How to download...

Page 169: ...extra button It contains a capacitive touch sensor that senses small changes in the electric field when pressed or touched just like your phone or tablet screen do When you press it you can activate t...

Page 170: ...roject 9 Speaker hex Or you could edit code step by step in the editing area 1 Delete block on start and forever 2 Enter Input module to find and drag on logo pressed Click the little triangle to find...

Page 171: ...lock 5 Enter Basic module to find and drag show icon into on logo touched block 6 Enter Input module to find and drag on logo pressed choose released establish variable time Enter Variables module to...

Page 172: ...Variables module to find and drag start into 0 on the right side of 0 0 8 Enter Basic module to find and drag show number into on logo released block Enter Math module to find and drag square root 0...

Page 173: ...173 www keyestudio com side of 0 0 and change the 0 on the right side to 1000 Complete Program...

Page 174: ...JavaScript and Python language code 4 Test Results After uploading the test code to micro bit main board V2 and powering the board via the USB cable the LED dot matrix exhibits the heart pattern when...

Page 175: ...u clap the microphone LED indicator turns on Since it can measure the intensity of sound you can make a noise scale or disco lighting changing with music The microphone is placed on the opposite side...

Page 176: ...load File Type Path File Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project 11 Microphone 1 Project 11 Microphone 1 hex Or you could edit code step by step in the editing area 1...

Page 177: ...yestudio com 3 Copy once Click the little triangle of lond to choose quiet Click the little triangle of to choose Complete Program Select JavaScript and Python to switch into JavaScript and Python lan...

Page 178: ...ing test code to micro bit main board V2 and powering the board via the USB cable the LED dot matrix displays pattern when you claps and pattern when it is quiet around How to download How to quick do...

Page 179: ...Enter Advanced module choose Serial to find and drag serial redirect to USB into on start block Enter Variables module choose Make a Variable input maxSound click OK variable maxSound is established...

Page 180: ...ind and drag show number into then Enter Variables module to find and drag maxSound into 0 Establish variable soundLevel Enter Variables module to find and drag set soundLevel to 0 into else Enter Inp...

Page 181: ...soundLevel into the 0 behind of Change the 0 behind up to 255 Enter Logic module to find and drag if true then into else block Enter Logic module to find and drag 0 0 into then Enter Variables module...

Page 182: ...182 www keyestudio com Enter Variables module to find and drag set maxSound to 0 into the second then Enter Variables module to find and drag soundLevel into the 0...

Page 183: ...183 www keyestudio com Complete Program Select JavaScript and Python to switch into JavaScript and Python language code...

Page 184: ...184 www keyestudio com...

Page 185: ...pload test code to micro bit main board V2 power the board via the USB cable and click Show console Device as shown below How to quick download When the sound is louder around the sound value shows in...

Page 186: ...ng the button A the LED dot matrix displays the value of the biggest volume please note that the biggest volume can be reset via the Reset button on the other side of the board while when clapping the...

Page 187: ...unicate with a variety of Bluetooth devices including smart phones and tablets In this project we mainly concentrate on the Bluetooth wireless communication function of this main board Linked with Blu...

Page 188: ...by step 3 Procedures For Apple devices enter this link https www microbit org get started user guide ble ios with your computer first and then click Download pairing HEX file to download the Micro Bi...

Page 189: ...189 www keyestudio com...

Page 190: ...190 www keyestudio com...

Page 191: ...nect your Apple device with Micro Bit main board V2 Firstly turn on the Bluetooth of your Apple device and open the APP micro bit to select item Choose micro bit to start pairing Bluetooth Please make...

Page 192: ...192 www keyestudio com Secondly click Pair a new micro bit...

Page 193: ...s button A and B at the same time do not release them until you are told to and press Reset Power button for a few seconds Release the Reset Power button you will see a password pattern shows on the L...

Page 194: ...194 www keyestudio com...

Page 195: ...195 www keyestudio com...

Page 196: ...196 www keyestudio com Set the password pattern on your Apple device as the same pattern showed on the matrix and click Next Still click Next and a dialog box props up as shown below Then click Pair...

Page 197: ...197 www keyestudio com A few seconds later the match is done and the LED dot matrix displays the pattern...

Page 198: ...198 www keyestudio com...

Page 199: ...199 www keyestudio com After the match with Bluetooth write and upload code with the App Click Create Code to enter the programming page and write code Click and the box appears and then select Create...

Page 200: ...200 www keyestudio com...

Page 201: ...201 www keyestudio com...

Page 202: ...202 www keyestudio com Name the code as 1 and click to save it...

Page 203: ...keyestudio com Click the third item Flash to enter the uploading page The default code program for uploading is the one saved just now and named 1 and then click the other Flash to upload the code pr...

Page 204: ...204 www keyestudio com...

Page 205: ...205 www keyestudio com...

Page 206: ...206 www keyestudio com If the code is uploaded successfully a few seconds later the App will emerge as below and the LED dot matrix of the Micro Bit main board V2 will exhibit a heart pattern...

Page 207: ...ry out with the help of external sensors of this turtle car Attention to avoid burning the the Micro bit main board V2 please remove the USB cable and the external power from the board before fix it w...

Page 208: ...hen high level is input like a normal LED 2 Experimental Preparation Insert micro bit board into slot of keyestudio 4WD Mecanum Robot Car Place batteries into battery holder Dial power switch to ON en...

Page 209: ...Path File Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project 13 Colorful Lights 1 hex Project 13 Colorful Lights 1 hex Or you could edit code step by step in the editing area 1...

Page 210: ...io com Compete Program Click JavaScript to view the corresponding JavaScript code run on start once to start the program open the colorful light on the left of the car open the colorful light on the r...

Page 211: ...211 www keyestudio com Code 2 File Type Path File Name...

Page 212: ...2 hex Project 13 Colorful Lights 2 hex Or you could edit code step by step in the editing area 1 click MecanumRobot to find and drag to forever Copy once Click the little triangle behind Left to choos...

Page 213: ...om Put them in forever Complete Program In the forever instruction block the program runs cyclically Turn on the 2 colorful lights of the car Wait for 1 second Turn off the 2 colorful lights of the ca...

Page 214: ...cro bit board and dial POWER switch to ON end 2 RGB lights of smart car emit red green blue indigo dark red yellow and white color cyclically Download code 2 to micro bit board 2 RGB lights show diffe...

Page 215: ...In this lesson 3 sets of test code are provided to make the 4 WS2812 RGB LEDs display different effects 2 Experimental Preparation Insert micro bit board into slot of keyestudio 4WD Mecanum Robot Car...

Page 216: ...hex Or you could edit code step by step in the editing area a Enter Neopixel set strip to Neopixel at pin P0 with 24 leds as RGB GRB format b Place it into on start block c Signal end P8 of WS2812 RG...

Page 217: ...Click Basic to move pause ms 100 block into forever block Then set to 1000ms Copy code string for eight times and click red to respectively set to orange yellow green blue indigo violet purple and wh...

Page 218: ...218 www keyestudio com Complete Code...

Page 219: ...219 www keyestudio com...

Page 220: ...All RGB lights show orange color Delay in 1000ms All RGB lights show yellow color Delay in 1000ms All RGB lights show green color Delay in 1000ms All RGB lights show blue color Delay in 1000ms All RG...

Page 221: ...File Type Path File Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project 14 WS2812 RGB LEDs 2 hex Project 14 WS2812 RGB LEDs 2 hex a Enter Neopixel set strip to Neopixel at pin P0...

Page 222: ...P8 of micro bit So we set to P8 d Smart car has 4 pcs WS2812 RGB lights so set to 4 leads Click Loops to drag for index from 0 to 4 do into forever block Change 4 into 3 Click Neopixel to move block...

Page 223: ...Place it into for index from 0 to 3 do block Click Variables to move index into 0 box 5 Click Neopixel to move strip show into for index from 0 to 3 do block 6 Tap Basic to move pause ms 100 block int...

Page 224: ...224 www keyestudio com Replicate code string for eight times and place them into forever block Click red to respectively choose orange yellow green blue indigo violet purple and white...

Page 225: ...225 www keyestudio com Complete Code...

Page 226: ...Turn off 4 pcs WS2812 RGB lights Set index of WS2812 RGB lights to red color Strip shows Delay in 100ms For index from 0 to 3 execute the program under do block Turn off 4 pcs WS2812 RGB lights Set i...

Page 227: ...227 www keyestudio com...

Page 228: ...et the index of WS2812 RGB lights to indigo color Strip shows Delay in 100ms For index from 0 to 17 execute the program under do block Turn off all RGB on strip Set the index of WS2812 RGB lights to v...

Page 229: ...Strip shows Delay in 100ms For index from 0 to 3 execute the program under do block Turn off 4 pcs WS2812 RGB lights Set the index of WS2812 RGB lights to purple color Strip shows Delay in 100ms For...

Page 230: ...230 www keyestudio com Click JavaScript to switch into the corresponding JavaScript code...

Page 231: ...2 folder Makecode Tutorial Makecode Code Project 14 WS2812 RGB LEDs 3 hex Project 14 WS2812 RGB LEDs 3 hex Or you could edit code step by step in the editing area a Enter Neopixel set strip to Neopixe...

Page 232: ...2812 RGB lights set to 4 leads Click Variables Make a Variable Input R to build up variable R We create variable G and B in same way Drag set B to 0 into on start block Copy set B to 0 twice and click...

Page 233: ...0 into for index from 0 to 3 do block Click B to choose R Go to Math to drag block pick random 0 to 10 into 0 box Change 0 into 10 10 into 255 Replicate block twice and place them into for index from...

Page 234: ...more strip set pixel color at 0 to red Leave it in the block for index from 0 to 3 do block Drag block red 255 green 255 blue 255 into red box Tap Variables to move index block into 0 box Separately d...

Page 235: ...235 www keyestudio com Click Neopixel to move strip show block under pause as 500...

Page 236: ...236 www keyestudio com Complete Code...

Page 237: ...block forever runs cyclically When the value of index is in 0 3 execute the program under do block Set variable R to random number in 10 255 Set variable G to random number in 10 255 Set variable B to...

Page 238: ...oad Project 15 Servo 1 Project Description For those DIY smart cars they often have the function of automatic obstacle avoidance In the DIY process we need a servo to control the ultrasonic module to...

Page 239: ...the servo receives the signal sent by MCU or receiver and produces a reference signal with a period of 20ms and width of 1 5ms then compares the acquired DC bias voltage to the voltage of the potentio...

Page 240: ...the same signal may have different rotation angle More details 3 Parameters Working voltage DC 4 8V 6V Operating angle range about 180 at 500 2500 sec Pulse width range 500 2500 sec No load speed 0 1...

Page 241: ...l Preparation Insert micro bit board into slot of keyestudio 4WD Mecanum Robot Car Place batteries into battery holder Dial power switch to ON end Connect micro bit to computer by USB cable Open onlin...

Page 242: ...ex Or you could edit code step by step in the editing area 1 Click Variables motor Make a Variable name create a variable named angle set the value to 0 and then put it into on start 2 Click Loops to...

Page 243: ...243 www keyestudio com into Click of Variable and of Math put variable angle on the left and change the umber on the right to 1 put it into Put behind and add delay in 10ms...

Page 244: ...244 www keyestudio com Copy once and change the of to Complete Program...

Page 245: ...runs only once to start the program Set the initial value of the angle variable to 0 In the forever command box the program runs cyclically Cycle 180 times Rotate the servo to angle Angle variable inc...

Page 246: ...246 www keyestudio com 6 Test Results After uploading the test code and dial POWER switch to ON end the servo rotates from 0 degree to 180 degrees How to download How to quick download...

Page 247: ...gear reduction motor which is developed on the ordinary DC motor It has a matching gear reduction box which provides a lower speed but a larger torque Furthermore different reduction ratios of the bo...

Page 248: ...m Micro bit motor driver shield comes with PCA9685PW and TB6612FNG chip In order to save the IO port resource we control the rotation direction and speed of two DC gear motors with TB6612FNG chip Deta...

Page 249: ...249 www keyestudio com Back...

Page 250: ...250 www keyestudio com...

Page 251: ...251 www keyestudio com 2 Experimental Preparation Insert micro bit board into slot of keyestudio 4WD Mecanum Robot Car Place batteries into battery holder Dial power switch to ON end...

Page 252: ...step by step add MecanumRobot extension library first How to add MecanumRobot extension 3 Test Code Code 1 File Type Path File Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project...

Page 253: ...lick the little triangle behind Motor to choose Lower_left Upper_right Lower_right respectively and put them all in forever 2 Click Basic to find and drag pause ms 100 to forever set delay in 2000ms 3...

Page 254: ...otor speed to 75 and rotate clockwise Set the speed of the rear left motor to 75 and the direction to rotate clockwise Set the front right motor speed to 75 and the direction to rotate clockwise Set t...

Page 255: ...255 www keyestudio com Code2 Code path File Type Path File Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project 16 Motor 2 hex Project 16 Motor 2 hex...

Page 256: ...256 www keyestudio com Or you could edit code step by step in the editing area 1 Drag and copy three times click the little triangle behind run to choose as shown...

Page 257: ...eversed Set the front right motor speed to 75 and th direction is reversed Set the right rear motor speed to 75 and th direction is reversed Wait for 2 seconds Set the front left motor speed to 75 and...

Page 258: ...258 www keyestudio com Click JavaScript to view the corresponding JavaScript code...

Page 259: ...dial POWER switch to ON end Smart car goes forward for 2s and stops for 2s Download code 2 to micro bit board the car goes forward for 2s turns back for 2s turn left for 2s turn right for 2s and stop...

Page 260: ...rs TCRT5000 IR tube has an IR emitting tube and a receiving tube Low level 0 is output when IR transmitting tube emits IR signals to receiving tube high level 1 will be output when smart car runs alon...

Page 261: ...rd which is controlled by the P1 and P2 of the micro bit The left TCRT5000 infrared pair tube on the sensor is controlled by P1 and the right one by P2 After putting a white paper on the bottom of the...

Page 262: ...by step add MecanumRobot extension library first How to add MecanumRobot extension 4 Test Code Code1 File Type Path File Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project 17 1...

Page 263: ...d pin P0 Move digital read pin P0 into 0 box The right tracking sensor is controlled by P14 Then change P0 into P14 and x into digital signal 2 Click Advanced Serial to find and drag t forever input l...

Page 264: ...264 www keyestudio com Copy once and change Leftto Right Drag 3 Click Basic to find and drag pause ms 100 to forever and set delay in 200ms Complete Program...

Page 265: ...digital signals read by right line tracking sensors The on start command block runs only once to start program Serial redirection USB In the forever instruction block the program runs cyclically Write...

Page 266: ...66 www keyestudio com Code 2 Code path File Type Path File Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project 17 1 Detect Line Tracking Project 17 1 Detect Line Tracking Sensor 2...

Page 267: ...ck OK to establish variable LL To establish variable RR in the same way Find and drag set RR to 0 to on start Copy set RR to 0 once and place it to on start Click the little triangle behind RR to choo...

Page 268: ...LL to RR and Left to Right 4 Click Logic to find and drag if true then else to forever Click twice and find and drag an and to true Drag a to and 5 Click Variables to find and drag LL to the left sid...

Page 269: ...o com Copy LL 1 once and place it to the right of and Click the little triangle behind LL to choose RR and change the 0 to 1 6 Click Basic to find and drag show leds to the first then Click the blocks...

Page 270: ...270 www keyestudio com 7 copy LL 0 and RR 1 once and place it behind the first else if change the first 0 to 1 and the first 0 behind LL to 1 others remain unchanged...

Page 271: ...271 www keyestudio com 8 Click Basic to find and drag show leds to the second then Click the blocks to form pattern...

Page 272: ...272 www keyestudio com 9 Copy LL 1 and RR 0 once and place it to else if and change the first number 1 behind LL to 0...

Page 273: ...273 www keyestudio com 10 Click Basic to find and drag show leds to the third else Click these blocks to form the pattern...

Page 274: ...274 www keyestudio com 11 Click Basic to find and drag show leds to else Click these blocks to form the pattern...

Page 275: ...275 www keyestudio com Complete Program...

Page 276: ...Set the variable RR to the digital signal read on t 1 0 When the variables LL 0 and RR 1 are esta execute the program under then The left side of the LED dot matrix displays the When the variables LL...

Page 277: ...the micro bit LED dot matrix displays a pattern and the indicator light on the left side of the tracking sensor lights up When only the right TCRT5000 infrared pair tube on the sensor detects a white...

Page 278: ...t car The micro bit board will analyze the signals and control smart car to show line tracking function 2 The Working Principle The smart car will make different moves according to the value received...

Page 279: ...ecode editor Import Hex profile How to import or click New Project and drag blocks step by step add MecanumRobot extension library first How to add MecanumRobot extension Warning The 2 way tracking se...

Page 280: ...ath File Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project 17 2 Line Tracking Smart Car hex Project 17 2 Line Tracking Smart Car hex Or you could edit code step by step in the e...

Page 281: ...281 www keyestudio com and to decide Click Functions of Advance and then tap Make a Function change doSomething to car_forward car_back car_left car_right...

Page 282: ...282 www keyestudio com respectively...

Page 283: ...83 www keyestudio com Click Functions of Advance to find and drag to the first if and drag to the first else if Find and drag to the last else Click MecanumRobot to find and drag to the second else if...

Page 284: ...284 www keyestudio com Complete Program...

Page 285: ...ard at a speed of 40 The rear right motor rotates forward at a speed of 40 Backward function The front left motor reverses the speed is 40 The rear left motor reverses the speed is 40 The front right...

Page 286: ...286 www keyestudio com...

Page 287: ...Results Download code to micro bit and dial POWER to ON end line tacking car goes forward along black line Note turn on the switch at the back of micro bit car the width of black line should be large...

Page 288: ...e ultrasonic sensor is being used in a wide range of electronics projects for creating obstacle detection and distance measuring application as well as various other applications As the above picture...

Page 289: ...P16 port on the micro bit motor drive backplane The Trig T pin is controlled by P15 of the micro bit and the pin of Echo E the P16 2 Working Principle Pull down TRIG then trigger high level signals w...

Page 290: ...DC Working current 15mA Working frequency 40khz Maximum detection distance about 3m Minimum detection distance 2 3cm Precision up to 0 2cm Sensing angle less than 15 degrees Input trigger pulse 10us T...

Page 291: ...h File Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project 18 1 Ultrasonic Ranging hex Project 18 1 Ultrasonic Ranging hex Or you could edit code step by step in the editing area...

Page 292: ...292 www keyestudio com 0 on the right side of serial write value x 0 and change the x on the left side of to distance 2 find and drag of Basic and change 100 to 200and place it behind Complete Program...

Page 293: ...code to micro bit keep USB cable connected dial POWER switch to ON end The distance value will be displayed on monitor How to quick download The on start command block runs on Serial redirection USB I...

Page 294: ...294 www keyestudio com The monitor shows the distance between the obstacle and ultrasonic sensor as shown below When the distance is less than 10cm the passive buzzer of smart car emits sound...

Page 295: ...click Options to select SerialPort Set COM port and 115200 baud rate the baud rate of USB serial communication of Micro bit is 115200 through the test Click OK and Connect CoolTerm serial monitor dis...

Page 296: ...296 www keyestudio com...

Page 297: ...d car expansion board to make an ultrasonic avoidance car Its principle is to detect the distance between the car and obstacle by ultrasonic sensor and control the motion of smart car 2 Experimental P...

Page 298: ...estudio com Open online Makecode editor Import Hex profile How to import or click New Project and drag blocks step by step add MecanumRobot extension library first How to add MecanumRobot extension 3...

Page 299: ...299 www keyestudio com 4 Test Code Code path...

Page 300: ...8 2 Ultrasonic Avoidance Car hex Or you could edit code step by step in the editing area 1 Enter Basic show icon Place it into on start and click the triangle button to select pattern 4 Click Variable...

Page 301: ...ever Click MecanumRobot to find and drag Ultrasonic to the 0 behind the to 6 Click Logic to find and drag if true then else to forever Find and drag to true Click Variables to find and drag distance o...

Page 302: ...302 www keyestudio com 7 Click Funtionsto of Advance to find and drag Click MecanumRobot to find and drag to then Click Basic to find and change the 100 to 500...

Page 303: ...yestudio com 8 Click MecanumRobot to find and drag and change the 0 to 180 Copy once Click Variables to find and drag set distance_l to 0 Click MecanumRobot to find and drag Ultrasonic to 0 behind to...

Page 304: ...304 www keyestudio com 9 Copy once Change the 180 to 0 distance_l to distance_r and others remain unchanged...

Page 305: ...dio com 10 Click Logic to find and drag if true then else Find and drag to true Click Variables to find and drag distance_l to the left of Click the little triangle behind to choose Change the 0 behin...

Page 306: ...306 www keyestudio com 11 Click Funtionsto of Advance to find and drag Click MecanumRobot to find and drag Change the 0 to 90 Click Basic to find and drag and change the 100 to 300...

Page 307: ...307 www keyestudio com 12 Change to and place it in the first else...

Page 308: ...308 www keyestudio com 11 Click Funtionsto of Advance to find and drag and place it to the second else...

Page 309: ...309 www keyestudio com Complete Program...

Page 310: ...310 www keyestudio com...

Page 311: ...311 www keyestudio com Click JavaScript to view the corresponding JavaScript code...

Page 312: ...Test Results Download code to micro bit dial to ON end and dial POWER to ON end When the obstacle distance is greater than 20cm the car goes forward on the contrary smart car turns left How to downlo...

Page 313: ...g sensor Next we will combine ultrasonic sensor with car shield to make an ultrasonic follow car The ultrasonic sensor detects the obstacle distance and control the motion status of car 2 Experimental...

Page 314: ...icro bit to computer by USB cable Open online Makecode editor Import Hex profile How to import or click New Project and drag blocks step by step add MecanumRobot extension library first How to add Mec...

Page 315: ...yestudio com 4 Test Code Code path File Type Path File Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project 18 3 Ultrasonic Follow Smart Car hex Project 18 3 Ultrasonic Follow Smar...

Page 316: ...ton to select pattern 2 Click MecanumRobot to find and drag to on start and change the angle 0 to 90 1 Click Variables and then click Make a Variable the dialog box New variable name pops up fill it w...

Page 317: ...and drag if true then else to forever Find and drag to true Click Variables to find and drag distance to the left side of Click the little triangle behind to choose Change the 0 behind to 10 5 Click...

Page 318: ...318 www keyestudio com 6 change the 10 to 20 car_back to car stop 7 change the 20 to 40 car stop to car forward...

Page 319: ...319 www keyestudio com Place car stop to the last else Complete Program...

Page 320: ...320 www keyestudio com Click JavaScript to view the corresponding JavaScript code...

Page 321: ...321 www keyestudio com 5 Test Results Download code to micro bit dial POWER switch to ON end on shield smart car could follow the obstacle to move How to download How to quick download...

Page 322: ...rs and satellite signal receivers Infrared remote control is composed of infrared transmitting and infrared receiving systems that is an infrared remote control and infrared receiving module and a sin...

Page 323: ...by judging what key is pressed by the remote control Infrared receiver we use is an infrared receiver module Mainly composed of an infrared receiver head it is a device that integrates reception ampli...

Page 324: ...ion Insert micro bit board into slot of keyestudio 4WD Mecanum Robot Car Place batteries into battery holder Dial power switch to ON end Connect micro bit to computer by USB cable Open online Makecode...

Page 325: ...mote Control hex Click Advanced Serial serial redirect to USB Place it into on start block Enter IrRemote connect IR receiver at P0 Put it into on start block IR receiving module is controlled by P9 o...

Page 326: ...Go to Ir Remote IR button Place it into 0 box Click Advanced Serial serial write value x 0 Put it into forever block Change x into IR Enter Variables to move block val into 0 box behind Drag out bloc...

Page 327: ...switch into the corresponding JavaScript code on start command block runs once to start program Serial redirect to USB Connect IR receiver to P9 The program under the block forever runs cyclically Set...

Page 328: ...kit is not inclusive of batteries We recommend you to purchase them online battery type CR2025 Make sure IR remote is good before test There is a tip for you to check it Open the cellphone camera mak...

Page 329: ...329 www keyestudio com How to quick download Make IR remote control point at IR receiver and press the button the serial monitor will display the corresponding key values as shown below...

Page 330: ...330 www keyestudio com Open CoolTerm click Options to select SerialPort Set COM port and 115200 baud rate Click OK and Connect CoolTerm serial monitor shows the key value as follows...

Page 331: ...331 www keyestudio com The key value is displayed as for your reference...

Page 332: ...332 www keyestudio com 19 2 IR Remote Control...

Page 333: ...batteries into battery holder Dial power switch to ON end Connect micro bit to computer by USB cable Open online Makecode editor Import Hex profile How to import or click New Project and drag blocks s...

Page 334: ...334 www keyestudio com 3 Flow Chart 4 Test Code Code path...

Page 335: ...emote Control hex Project 19 2 IR Remote Control hex Or you could edit code step by step in the editing area 1 Create four functions controlling the car to move forward and back and turn left and righ...

Page 336: ...method find and drag set val2 to 0 to on start and copy it once to put into on start too Click the little triangle behind the first val2 to choose val 4 Click Variables to find and drag set val2 to 0...

Page 337: ...t side of remain unchanged click the little triangle behind to choose 6 Click Variables to find and drag set val2 to 0 into then find and drag val into the o behind to of set val2 to 0 7 Click Logic t...

Page 338: ...338 www keyestudio com Find and drag to true 8 Click Variables to find and drag val2 to the left side of and change the 0 on the right of to 70...

Page 339: ...339 www keyestudio com 9 Click Functions of Advance to find and drag to the second then...

Page 340: ...340 www keyestudio com 10 Copy val2 70 once and place it behind the first if change the 70...

Page 341: ...341 www keyestudio com behind to 68 11 Click Functions of Advance to find and drag to the...

Page 342: ...ww keyestudio com second then 2 Copy val2 68 once and place it behind the second else if change the 68 behind to 67 place it in the forth then Click Functions of Advance to find and drag to the forth...

Page 343: ...343 www keyestudio com 13 Copy val2 67 once and put it behind of the third else if change the number 67 to 21 click Functions of Advance to find and drag to the fifth then...

Page 344: ...344 www keyestudio com 14 Copy val2 21 once and place it behind the fourth else if change the the number 21 behind to 64 Click MecanumRobot to find and drag to the sixth then...

Page 345: ...345 www keyestudio com Complete Program...

Page 346: ...he variable val2 to 0 In the forever instruction b Set val to IR button When the variable val 0 program under then Set variable val2 to val When val2 70 is established then The car goes forward When v...

Page 347: ...OWER to ON end Make IR remote control point at micro bit and press the button to control smart car to move button makes smart car move forward stands for turning left implies rightward turning indicat...

Page 348: ...Description Micro bit main board comes with a built in Bluetooth which can be used to communicate with it And the Micro bit can also be controlled by Bluetooth or transmit signals back to smartphone o...

Page 349: ...Robot Car Place batteries into battery holder Dial power switch to ON end Connect micro bit to computer by USB cable Open online Makecode editor Import Hex profile How to import or click New Project...

Page 350: ...Name Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project 20 1 Read Bluetooth Data hex Project 20 1 Read Bluetooth Data hex Or you could edit code step by step in the editing area Ente...

Page 351: ...ake a Variable New variable name dialog box Input connected and click OK to create variable connected Drag set connected to 0 under block show icon and change 0 into 1 Go to Loops to move block while...

Page 352: ...en drag out set rec_data to 0 and place it into block while connected 1 do block Click Bluetooth more bluetooth uart read until new line Keep it into 0 box and click triangle button to select Go to Ad...

Page 353: ...353 www keyestudio com And combine variable rec_data with serial write string block Click Advanced Serial serial write line and edit code string as follows...

Page 354: ...Click Bluetooth to drag out on bluetooth disconnected Go to Bluetooth on bluetooth disconnected Copy show icon block and keep it into block on bluetooth disconnected Click triangle button to select pa...

Page 355: ...355 www keyestudio com...

Page 356: ...ED dot matrix shows pattern Set variable connected to 1 When connected 1 the code under do block will be executed Set rec_data to bluetooth uart read until Serial port prints rec_data Print a blank sp...

Page 357: ...y step you need to set as follows after finishing test code Click However you could skip this step if you directly import test code After setting download code to micro bit board don t plug off USB ca...

Page 358: ...ooth of the mobile phone iPad and then click the connect button control in the upper left corner of the APP interface to perform a Bluetooth search In the search results click BCC micro bit After a fe...

Page 359: ...ll to install the App C Click Open or click the application mecanum_robot on the mobile phone desktop to open the APP and a dialog box appears In the dialog box click Allow to turn on the Bluetooth of...

Page 360: ...Click on the upper right corner to search for Bluetooth and click connect a few seconds later the Bluetooth is paired Open CoolTerm click Options to select SerialPort Set COM port and 115200 baud rat...

Page 361: ...361 www keyestudio com Point at micro bit board and press the icons on APP the corresponding characters are shown on CoolTerm monitor Through the test we get the function of every icon as shown below...

Page 362: ...362 www keyestudio com...

Page 363: ...Smart Car 1 Project Description In this lesson we will control the smart car to perform multipurpose function 2 Experimental Preparation Insert micro bit board into slot of keyestudio 4WD Mecanum Robo...

Page 364: ...Project and drag blocks step by step add MecanumRobot extension library first How to add MecanumRobot extension As the Bluetooth and extension radio can t work together therefore their extension libra...

Page 365: ...365 www keyestudio com Hex file KS4031 4032 folder Makecode Tutorial Makecode Code Project 20 2 Multi purpose Smart Car hex Project 20 2 Multi purpose Smart Car hex Complete Code...

Page 366: ...366 www keyestudio com...

Page 367: ...367 www keyestudio com Click JavaScript to view the corresponding JavaScript code...

Page 368: ...Results This experiment combines the previous projects to make the car to perform actions by Bluetooth Enter Makecode online editor Projecting Settings enable No Pairing you could skip this step if y...

Page 369: ...9 Resources Download PDF files https fs keyestudio com KS4031 4032 BBC microbit MicroPython https microbit micropython readthedocs io en latest tutorials introducti on html MicroPython https docs ope...

Reviews: