background image

Welcome to the DFRobot blog

 

www.dfrobot.com/blog-tag-microbit.html

 

 

 

4

 / 

86

 

Components list ......................................................................................................................................... 67

 

Connection ................................................................................................................................................. 68

 

Program ....................................................................................................................................................... 68

 

Exercises ...................................................................................................................................................... 70

 

Project 3: Remote Doorbell ...................................................................................................................... 71

 

Component list ........................................................................................................................................... 71

 

Connection ................................................................................................................................................. 72

 

Program ....................................................................................................................................................... 73

 

Exercise ........................................................................................................................................................ 76

 

Project 4

Escape the maze ................................................................................................................... 77

 

Components list ......................................................................................................................................... 77

 

Connection ................................................................................................................................................. 78

 

Program ....................................................................................................................................................... 78

 

Exercise ........................................................................................................................................................ 85

 

 

Remember to check out the DFRobot blog for more tutorials, projects and latest trends. The link 
can be found on the top left corner of the page. 

 

 

Содержание BOSON KIT

Страница 1: ...A STARTER GUIDE OF BOSON KIT FOR MICRO BIT...

Страница 2: ...oject 8 STEP 4 Download the program and upload to micro bit 10 Chapter 2 What Makes a Machine Come to Life 14 Interactive devices 14 Input Unit sensor 14 Control Unit micro bit 14 Output Unit actuator...

Страница 3: ...further 37 Project 1 Electronic Candle 37 Components list 37 Connection 38 Program 38 Project 2 Automatic Door 42 Components list 42 Connection 43 Program 43 Project 3 Music Box 48 Components list 48...

Страница 4: ...cises 70 Project 3 Remote Doorbell 71 Component list 71 Connection 72 Program 73 Exercise 76 Project 4 Escape the maze 77 Components list 77 Connection 78 Program 78 Exercise 85 Remember to check out...

Страница 5: ...omes with a variety of on board modules including a 5x5 LED matrix also supports light detection 2 programmable buttons motion detector Compass and Bluetooth Smart module Additionally you may attach m...

Страница 6: ...n our daily lives How to Use micro bit If you are new to micro bit you can start with the online programming platform The MakeCode Editor to learn about how to program the micro bit Before getting sta...

Страница 7: ...can be used as a reference for other operating systems STEP 1 Open MakeCode Visit the MakeCode page from the following link https makecode microbit org STEP 2 Connect micro bit to computer Micro bit...

Страница 8: ...rogramming we should make sure that the mainboard is recognized by the computer When micro bit is connected a MICROBIT directory will show up in My Computer STEP 3 Start a New Project Before starting...

Страница 9: ...of programming you can always check how your program looks like the through the window Function area Where you can find all the function blocks including input output loop logic etc Programming area...

Страница 10: ...our program we can now download it from the website and uploaded to micro bit We can also rename the project and save it in the browser The project will stay in my stuff Before downloading we can chec...

Страница 11: ...Welcome to the DFRobot blog www dfrobot com blog tag microbit html 11 86 Click Download in the lower part of the simulation window and select Save As in the pop up dialog box...

Страница 12: ...com blog tag microbit html 12 86 Choose to save the hex file to MICROBIT Disk and click Save During the process of downloading the power indicator on the back of micro bit will blink When completed i...

Страница 13: ...g microbit html 13 86 Now you are all good for basic setups Remember to visit our blog to check out more micro bit projects Please also leave a comment if there you have question or new idea to share...

Страница 14: ...ons based on these information to change the material environment Specifically your friend for example says hello to you and you respond hello Here your ears act as input units your brain acts as a co...

Страница 15: ...However what actually controls the behavior of our physical body is our mind The program here is like our mind and what we will explain is how to setup the mind of the micro bit so it will do whatever...

Страница 16: ...erious Micro bit We will start our first project a simple emojis panel to get a bit more familiar with what we have just learned in the previous chapter Emojis can be seen on almost every smartphone a...

Страница 17: ...1 Start a new project You may go back to the last chapter if you forget how to do it STEP 2 Click Basic at the top of the function area and find the show leds function STEP 3 The module on start will...

Страница 18: ...the show leds function to the programming area and place it in on start When show leds function is inside the on start module you can then click the light blue dot inside the block to edit the patter...

Страница 19: ...block To help us remember we may rename it as heart STEP 6 Click Download to save the file to MICROBIT to the computer or you may directly save it to micro bit If everything goes well the micro bit wi...

Страница 20: ...Welcome to the DFRobot blog www dfrobot com blog tag microbit html 20 86 Exercises Try to design an emoji that can switch between two different patterns...

Страница 21: ...lashing LED Light In the previous part we have learnt how to program the LED penal to make our own emojis In this chapter we will connect an external LED module and learn how to light it up and make i...

Страница 22: ...s makecode microbit org and start a new project STEP 2 This time Since the LED module is connected to P1 of the micro bit as an external component to control the LED we will need to set the status of...

Страница 23: ...e will take a further step to learn how to make it blink STEP 1 Start a new project You may always go back to the STEP 3 in chapter 1 if you forget how to do this STEP 2 Set the pin status of micro bi...

Страница 24: ...ertain period of time STEP 4 Put the Pause function into forever loop and adjusting the numbers Combine all the function blocks listed above altogether we will have the final program as below In this...

Страница 25: ...t As you have learnt how to light an external LED through micro bit we will now apply an external button module to control the LED Also we will learn how to set the brightness of the light by using a...

Страница 26: ...the LED turns off STEP 1 Connect the button module to P0 By reading the value of P0 micro bit will then get the status of the button To link the button with the LED we can write a simple program When...

Страница 27: ...d to determine whether the button is pressed or not If the status of the button equals 1 then we will know the button is being pressed vice versa STEP 3 If the button is pressed the external LED light...

Страница 28: ...ng program What the program does is to detect the status of the button and lights up the LED when the button is pressed Task 2 Knob controlled LED Goal in the part we will not only control the LED fro...

Страница 29: ...log input module which means it generates a signal range from 0 1023 by which controls the brightness of the LED correspondingly The analog read function is under Pins Also remember to set the pin to...

Страница 30: ...ed is to link the input directly to the output so that the LED will be under control of the knob Put the analog read function inside the analog write function then put them all inside the forever loop...

Страница 31: ...ild an electric fan that runs at different speed Before getting started we will have a quick review of how to switch on or off the fan with the button module After that we will learn how to control th...

Страница 32: ...ct the fan module to the P1 Electric fan eats power When connecting Boson modules we should notice that due to the power consumption of modules such as fans or servos an external power supply will be...

Страница 33: ...ill need to use the digital read function on P0 to first detect the status of the button The fan module connects to P1 Likewise to control the fan we will use the digital write function on P1 to switc...

Страница 34: ...ement will be skipped STEP 3 If the button is pressed the fan will be turned on otherwise it stays off The if else function under logic will help us make the choice depending on the status of the butt...

Страница 35: ...usly changes when the knob rotates STEP 1 Connect the circuit as below The button module used in task 1 should be replaced by a knob module STEP 2 We will be using the fan module here again To make th...

Страница 36: ...The fan module is now used as an analog output module and its value is also ranged from 0 1023 The analog write function can be found under Pins STEP4 Put the analog read function into analog write an...

Страница 37: ...e more about the micro bit In this chapter more sensors will be introduced to make your device smarter and more functional Project 1 Electronic Candle In this project we are going to make a device sim...

Страница 38: ...nect the sound sensor to P0 Connect the LED module to P1 Program To build an electronic candle we must first know how the sound sensor works We can connect the sound sensor to the micro bit and see ho...

Страница 39: ...rt Function if else and operator will be applied in this part Both of them should be placed into forever loop The if else function can be used to judge which number should be displayed Which means tha...

Страница 40: ...to the volume Also if the sensor is being too responsive you may need to change the 50 after the operator It also works the same way around if the sensor is not responsive Task 2 electronic candle Goa...

Страница 41: ...a very short time Sometimes it happens so fast that we won t be able to notice the change To solve this issue we will need to add a Pause function to extend the duration Say if the duration set to be...

Страница 42: ...er a convenient store the door opens automatically and sometimes along with the sound welcome In this lesson we are going to learn how to build an automatic door using a motion sensor which detects if...

Страница 43: ...ww dfrobot com blog tag microbit html 43 86 1 servo module 1 USB cable Connection Connect the servo to P0 Connect the button module motion sensor in the second part to P1 Program Task 1 Use the button...

Страница 44: ...nder Pins is used to control the servo Since the servo is connected to P0 we will leave the P0 as it is The number 180 is the angle that we want the servo to reach By changing this value we can set th...

Страница 45: ...86 STEP 3 By putting everything together we will end up with a program shown as below Need to notice that the servo has a relatively large power consumption so we will need to connect to the power sou...

Страница 46: ...he button module with the motion sensor STEP 2 The motion sensor is connected to P1 Thus we can read the value of the motion sensor Function used in this part is Pins digital read Remember to replace...

Страница 47: ...Welcome to the DFRobot blog www dfrobot com blog tag microbit html 47 86 STEP 4 By putting all above mentioned functions altogether we will have the final program as below...

Страница 48: ...music boxes in different shapes have always been popular in gift shops You must have been deeply touched by their ornate appearances and clever designs This lesson We will help you in building a smart...

Страница 49: ...since P0 is occupied by the audio jack it will no longer be available to connect other modules Program Task 1 Electronic music box Goal In this part we will learn how to let micro bit play a piece of...

Страница 50: ...ome to the DFRobot blog www dfrobot com blog tag microbit html 50 86 STEP 2 Since the dadadum lasts for 4 beats the rest ms function from Music is required for this part The final program is as follow...

Страница 51: ...Welcome to the DFRobot blog www dfrobot com blog tag microbit html 51 86...

Страница 52: ...kle Twinkle Little Star Firstly we will try to edit the first sentence of the Twinkle Twinkle Little Star Different tones and notes are required for editing the vocal frequency Tone Notes Twinkle Twin...

Страница 53: ...entence of the Twinkle Twinkle Little Star But can it become even smarter The motion sensor module will be our key again When combining it with the if else function the smart music box will come to li...

Страница 54: ...ll want to explore more about the micro bit Music boxes in our daily life always wear colorful lights Therefore the project to make colorful LED strip will be introduced here to help you building a di...

Страница 55: ...arn how to use micro bit to program the RGB LED strip STEP 1 The function block for controlling the RGB light strip is not listed in the tool box when we start a new project To add this function we ne...

Страница 56: ...e will first setup how many LEDs are included in the light strip and which pin it connects to Will need to put these two parameter in the function block as following After this we need to configure ho...

Страница 57: ...r these two numbers are the smaller the gradient changes The diagram will help you to have an overall understanding the meaning of each parameter try to adjust the parameter and see how the light effe...

Страница 58: ...turn on in a sequence STEP 1 The key to create an animation with the LED strip is to change the parameter of the light effect We will create a variable that changes throughout the time and use it to r...

Страница 59: ...up the initial condition by using while do function Use the logic operator to set the condition we will have when the number of LEDs to be lit is less than 7 the while do loop will make the LED light...

Страница 60: ...ge from function and put a pause 1000ms in the loop And here is what we have Task 3 RGB LED strip controlled by a sound sensor Goal What we will learn in this part is to use a sound sensor to control...

Страница 61: ...microbit html 61 86 STEP 2 When the value exceeds 40 and the total number of lighted LEDs is less than 7 one more LED lights up The sound sensor will be continuously detecting the value The flow chart...

Страница 62: ...e to the DFRobot blog www dfrobot com blog tag microbit html 62 86 STEP 3 Put the condition if the analog read P1 40 in the program that we build in the last part we will have the final program as fol...

Страница 63: ...another further step into the micro bit Project 1 Electronic Stabilizer Have you heard of the accelerometer The accelerometer measures the acceleration along 3 direction and it is now extremely popul...

Страница 64: ...inting upright regardless how we tile board Micro bit detects the gesture automatically through the accelerometer Gravitation force is also a form of acceleration and micro bit can detect the gravitat...

Страница 65: ...that the values of X and Y axis are close to zero and the Z axis is around 1000 mm S2 which roughly equals to the gravitational acceleration When we tilt the board the values of X and Y change When it...

Страница 66: ...180 degrees of the servo through the function map STEP 2 Fix the servo and expansion board with tape so that these two remain relatively still Note that the orientation of the servo needs to be the s...

Страница 67: ...Welcome to the DFRobot blog www dfrobot com blog tag microbit html 67 86 Project 2 DJ panel Components list 1 micro bit 1 Boson Expansion board 1 RGB LED strip 1 knob module 1 USB cable...

Страница 68: ...lly adjusting the rotation angle of the knob When the knob is turned by hand the value of P1 changes from 0 to 1023 and is divided into 8 small ranges corresponding to one octave Do Do and the number...

Страница 69: ...ill learn how to edit the if else function Firstly place the if else from Logic under forever loop As we may see from below that there lies a blue gear like icon circled in red as below at the top lef...

Страница 70: ...Music and pause ms from Basic will be taken to control the music The following is the finished program in this step STEP 4 Since there are only 7 LEDs so the eighth sound do can be expressed by a diff...

Страница 71: ...ay be quite a common issue that sometimes the ring is not loud enough to travel over rooms To solve this problem a wireless alarm may be helpful In the chapter we will learn how to make the doorbell t...

Страница 72: ...Connection We will need two micro bit in this project one is attached to the door bell and sends out message transmitting end the other receives the signal and controls the LED indicator receiving en...

Страница 73: ...ask1 Program the transmitter STEP 1 We have been quite familiar with the button module and the motion sensor however how can we send out their status through over radio To achieve this we will learn h...

Страница 74: ...e program inside the on radio received loop We will also need to program the receiver to make corresponding reaction based on the received number Notice the variable receivedNumber inside the on radio...

Страница 75: ...er The complete program will be looked like as following Task 2 Program the receiver STEP 1 The receiver is able to execute different action based on the received signal The flow chart below will help...

Страница 76: ...Welcome to the DFRobot blog www dfrobot com blog tag microbit html 76 86 Exercise Add a Please wait notice to the doorbell when someone rings the bell...

Страница 77: ...e maze Micro bit is trapped inside the maze with a time bomb Poor micro bit cannot move by itself However it sends out signal through the LED panel to lead the way We need to help him escape the maze...

Страница 78: ...we will need to let micro bit randomly generate some movements to simulate the maze Also micro bit should be able to know which way it tilts If the two directions match 1 point will be added to the f...

Страница 79: ...t four target directions respectively The function pick random under Math help us to get a random number from 0 3 STEP 2 Show the arrow image on the LED panel The arrow should correspond to the random...

Страница 80: ...t blog www dfrobot com blog tag microbit html 80 86 STEP 3 Use the on xxx gesture function under input to sense which direction the micro bit tilts The number inside the function loop represents four...

Страница 81: ...nction inside the loop so as to avoid identical directions appear in a row STEP 5 it s the time to add the bomb The bomb will start ticking as soon as the game begins Also we will use the RGB LED stri...

Страница 82: ...ag microbit html 82 86 We will be explaining the functions that we need to achieve it Note Micro bit needs extra time to process the data so the clock will run a bit slower than what we set The follow...

Страница 83: ...86 STEP 6 A scoring mechanism will be needed to tell us whether we made it to escape The following flow chat may give you an idea of how it works Remember to reset the score at the beginning of the p...

Страница 84: ...Welcome to the DFRobot blog www dfrobot com blog tag microbit html 84 86 STEP 8 Here is how the final program looks like...

Страница 85: ...tick faster to increase the difficulty Program the LEDs to make them flash at a pace based on the remaining time Unintuitive challenge Set different directions in pairs and see if you can still finish...

Страница 86: ...blog tag microbit html 86 86 Your journey of micro bit wouldn t stop here If you would like to share your ideas with us please visit the DFRobot blog and share your idea with us Welcome to the DFRobot...

Отзывы: