background image

Alphabot2 for micro:bit User Manual 

   

 

 

 

 

1

  / 

76

 

Alphabot2 for micro:bit 

User Manual 

 

 

 

 

Summary of Contents for Alphabot2

Page 1: ...Alphabot2 for micro bit User Manual 1 76 Alphabot2 for micro bit User Manual...

Page 2: ...apter 1 LED lights 8 JavaScript Blocks editor 8 Blocks 9 Lighting LEDs 10 Heart Beating 13 Display Text 14 Chapter 2 Buttons 15 Pressing 15 Pressing 2 16 Chapter 3 Sensors 18 Temperature Sensor 18 Acc...

Page 3: ...e 30 Lighting 31 Display different Colors 32 Blinky LEDs 33 Rainbow 34 Chapter 6 Moving Robot 35 Add Pakcage 36 Motors 37 Moving 38 Moving 2 40 Moving 3 41 Chapter 7 Infrared Obstacle Avoiding 42 Infa...

Page 4: ...ter 9 2 4g Radio 56 Add Package 56 radio communicating 56 Joystick for micro bit 58 Joystick for micro bit 2 62 Posture control 64 Chapter 10 Ultrasonic Obstacle Avoidancing 66 Ultrasonic sensor 67 Ob...

Page 5: ...O BIT The BBC micro bit is a pocket sized computer to learn programming for kids and beginners Nordic nRF51822 16 MHz 32 bit ARM Cortex M0 microcontroller Bluetooth 4 0 low energy 2 4GHz RF SoC 16kB R...

Page 6: ...and datasheet all these resources can be downloaded in Wiki https www waveshare com wiki AlphaBot2_for_micro bit 3 There may be mistakes in this guide due to the limit of time If you find them please...

Page 7: ...ED matrix of micro bit towards to outside 8 All the demo codes mentioned here are provided in Wiki Demo codes are based on make code programming environment of Microsoft The makecode tool supports Gra...

Page 8: ...ers and images here we will learn about coding these LEDs JAVASCRIPT BLOCKS EDITOR The link of online JavaScript Block Editor of BBC https makecode microbit org Accessing the editor There is divided t...

Page 9: ...Alphabot2 for micro bit User Manual 9 76 BLOCKS Blocks in Basic are mainly used for basic operation like LEDs controlling Run the code at the beginning Repeat the code forever at the background...

Page 10: ...e character at a time Draw selected icon on the LEDs Turn off all LEDs Draw an arrow on the LEDs LIGHTING LEDS Connecting the micro bit to computer via a micro USB cable the micro bit will show up on...

Page 11: ...them light on you can see that the LEDs of simulated micro bit light on as the codes Click Download to download the code to the drive of micro bit You can also save the HEX file to another place and t...

Page 12: ...Alphabot2 for micro bit User Manual 12 76...

Page 13: ...Alphabot2 for micro bit User Manual 13 76 HEART BEATING This code we use block show icon first display big heart icon then the small heart Repeat the code and it looks like heart beating Let s do it...

Page 14: ...anual 14 76 DISPLAY TEXT Here we use show string block to display text Hello on LEDs The text will scroll on LEDs character by character Tips To delete the blocks you can right click and delete it or...

Page 15: ...NG Blocks we use in this section are included in Input package With this block if A or B buttons on your micro bit are pressed codes are executed Coding the buttons to display characters A when button...

Page 16: ...o flash the code to your board Press buttons on micro bit to test if expected string is displayed PRESSING 2 There is another way to detect buttons In last section codes are run when button is pressed...

Page 17: ...block on it 2 Place show string block then clock icon to complete the codes as below 3 Connect your micro bit to PC click Download to flash the code to your board Press buttons on micro bit to test if...

Page 18: ...t temperature in degree Celsius It is embedded in the main chip nrf51822 which is used to detect the temperature of chip in fact Even temperature of chip is a little different with ambient temperature...

Page 19: ...mperature became higher ACCELEROMETER The accelerometer MMA8652 is integrated on the left bottom of micro bit Acceleration is a trend to move If we apply a force to an object in one direction then the...

Page 20: ...e coordinate of x y and z directions With these three values we could get the direction of accelerations If there is only acceleration of gravity the direction is downward We keep measuring values of...

Page 21: ...complete the script 4 Download the code to your micro bit shake your micro bit to see if arrows change MAGNETOMETER The compass chip is MAG3110 marked by red frame The compass can detect the earth s...

Page 22: ...text to fill screen to tell you that calibration step should be done first Then you should to fill the LED screen by tilting the micro bit After lighting all the LEDs a smiley is displayed to show yo...

Page 23: ...uenced by other magnetic fields 1 Place show number block to forever 2 Find block magnetic heading to number block 3 Add pause block for delay 4 Download the script to your micro bit and try it 5 Cali...

Page 24: ...micro bit User Manual 24 76 2 Drag light level block to bar block set max value to 255 3 Download the script to your micro bit and try 4 Open the flashlight of your mobile phone and try to light the...

Page 25: ...r micro bit to play sound or music you need to connect external speaker There is a buzzer on Alphabot2 for micro bit expansion board you can insert the micro bit to it Note Before you read this chapte...

Page 26: ...rthday and set it to repeat once 3 Download the script to your micro bit and test if the melody is played Tips sound is generated by shaking of object People speak by shaking our vocal cord in differe...

Page 27: ...Let s use blocks to simulate piano 1 Place play tone for block to forever set the tone to Middle C and 1 beat 2 Duplicate and complete the script as below 3 Download the script to your micro bit speak...

Page 28: ...We create a new project to play different melody when buttons are pressed 1 Place on button pressed block and set the start melody repeating on it 2 Duplicate and complete the script as below 3 Downlo...

Page 29: ...Alphabot2 for micro bit User Manual 29 76 CHAPTER 5 RGB LED Alphabot2 has four full color RGB LEDs which are programmable for colorful effect In this chapter we code the RGB LED...

Page 30: ...icro bit User Manual 30 76 ADD PACKAGE Before coding we should add Neopixel package click More icon on top right choose Add package Extensions then click neopixel After adding a blocks package Neopixe...

Page 31: ...lace Set item to NeoPixel at pin P8 with 4 leds as GRB format block to on start Variable item can be renamed Pin P8 is selectable and P8 is the default pin of Alpahbot2 s RGB LED 2 Place item show col...

Page 32: ...by dragging it to the left side 2 Place item set pixel color at 0 to red block This block can be found in Neopixel More This block can set the color of every pixel from 0 3 Duplicate and complete four...

Page 33: ...he last script to cycling RGB LED display 1 Place item rotate pixels by 1 block in forever This block can transfer the color of current pixel to next one 2 Place item show and pause ms blocks item sho...

Page 34: ...blocks can be created and founded in Variables package 3 Place change hue to 1 block in forever 4 Place item show rainbow from 1 to 360 the range of hue is 1 360 different hue values stand for differe...

Page 35: ...Alphabot2 for micro bit User Manual 35 76 CHAPTER 6 MOVING ROBOT We have learned how to control LEDs and buzzer In this chapter let s control the Alphabot2 and let it move...

Page 36: ...Alphabot2 for micro bit User Manual 36 76 ADD PAKCAGE Adding a package like what we do in last chapter Input the address on box https github com waveshare pxt AlphaBot2 Click AlphaBot2...

Page 37: ...ce Motor speed block after then This block is used to control one motor the range of speed is 255 to 255 bigger the number fast the speed Positive to forward and negative to backward 3 Duplicate and c...

Page 38: ...f both motors move backward robot will move backward If left motor moves backward or stop and right motor moves forward robot will turn left generally if the speed of two motors are different robot wi...

Page 39: ...Alphabot2 for micro bit User Manual 39 76 3 Duplicate and complete the script as below 4 Download the script to micro bit and test...

Page 40: ...er block can also be used to control motor 1 Place Forward speed 0 block in on start This block can directly control the robot to move in all directions 2 Place pause ms block 3 Duplicate and complete...

Page 41: ...d 150 for 2 sec block in on start With this block robot will move forward in speed 100 for 2 seconds then stop if there is not another setting 2 Duplicate and complete the script 3 Download the script...

Page 42: ...t2 Base board if you have assembled the Alphabot2 they are under the Ultrasonic sensor Every infrared sensor has one sender and one receiver infrared lights are sent from the sender if there is obstac...

Page 43: ...block to both sides of and 4 Place show string block 5 Duplicate and complete the scrip 6 Download the script to micro bit and test it 7 After downloading LEDs of micro bit will display A if obstacle...

Page 44: ...e last script to make robot to avoid obstacle 1 Place show string block with speed block to make robot turn right when obstacle is detected 2 Place pause ms block 3 Place Forward speed block after els...

Page 45: ...y module allows micro bit to send and receive Bluetooth signals With this feature we can control robot by our mobile phones via Bluetooth ADD PACKAGE To use Bluetooth we need to first add the supports...

Page 46: ...2 Place on Bluetooth connected and show string C blocks Make micro bit show C if Bluetooth is connected 3 Place Bluetooth disconnected and show string D blocks Make micro bit show D if Bluetooth is di...

Page 47: ...th service of your phone scanning and find the BBC micro bit device pair with it and connect After paring icon is displayed Note that you should delete paired micro bit device before a new pairing 7 O...

Page 48: ...t Note that only the device with BOUNDED suffix can be connected 9 After connecting control options are listed as below and LEDs matrix shows C 10 Then you can try to control micro bit by Bluetooth Cl...

Page 49: ...r micro bit User Manual 49 76 11 Click button option Press buttons of your micro bit The buttons icon in APP react the button event 12 Click LEDs option edit the LEDs matrix then clock SET DISPLAY or...

Page 50: ...bot2 for micro bit User Manual 50 76 13 Click Temperature option the current temperature is showed in APP Note We only start four services in the code so some of the services showed in APP are unavail...

Page 51: ...ify the last script to make it simpler 1 Click the icon on the top right More Project Setting check the first option No Pairing Required Anyone can connect via Bluetooth 2 Download the script to micro...

Page 52: ...fter setting scanning devices again BBC micro bit tozug 4 is listed then you can clock it to connect with micro bit Don t forget to delete the paired device the device with BOUNDED suffix 4 tozug this...

Page 53: ...Controller Click it to enter a control page with dual D pad eight buttons Click the top right three dots icon you can change the settings Every time virtual buttons are pressed related signals are se...

Page 54: ...n event from with value block can be found in Control package 3 MES_DPAD_CONTROLLER_ID is signal the event from APP 4 MICROBIT_EVT_ANT is the value of the event 5 MES_DPAD_CONTROLLER_ID and MICROBIT_E...

Page 55: ...D PAD CONTROLLER 2 In the Last script we only use fours buttons however as we know there is dual D Pad controller in APP which has eight buttons We modify the last script make micro bit show different...

Page 56: ...project you need at least two micro bit and one Joystick for micro bit ADD PACKAGE Add radio package first RADIO COMMUNICATING Note that you should 1 You need to set the two micro bit in one group us...

Page 57: ...t User Manual 57 76 3 User radio received block to receive string 4 Download the script to both micro bit and test 5 Expected result it that if the buttons of one micro bit are pressed A or B is showe...

Page 58: ...module with one joystick and four buttons Here we use it to control Robot via Radio 1 Add package We provide a package for joystick for micro bit you can add it with this address https github com wave...

Page 59: ...Alphabot2 for micro bit User Manual 59 76 module...

Page 60: ...The script for sender Download this script to one micro bit as sender which insert to joystick module 3 The script for receiver As we say you must set the receiver and sender in the same group Blocks...

Page 61: ...Alphabot2 for micro bit User Manual 61 76 Download this script to another micro bit as receiver which insert to Alphabot2...

Page 62: ...habot2 for micro bit User Manual 62 76 JOYSTICK FOR MICRO BIT 2 Modify the last two scripts make LEDs matrix show emoticons when four color buttons of joystick module are pressed 1 The script for send...

Page 63: ...Alphabot2 for micro bit User Manual 63 76 2 Script for receiver...

Page 64: ...phabot2 for micro bit User Manual 64 76 POSTURE CONTROL In chapter 3 we have described sensors accelerometer can be used to detect status of micro bit so we add the posture control part to last script...

Page 65: ...Alphabot2 for micro bit User Manual 65 76 1 Script for sender 2 Download the script to sender and test Robot will move when you tilt micro bit...

Page 66: ...Alphabot2 for micro bit User Manual 66 76 CHAPTER 10 ULTRASONIC OBSTACLE AVOIDANCING The eyes of the Alphabot2 is ultrasonic sensor we can use it to do obstacle avoidance...

Page 67: ...receiver as well Ultrasonic sensor can detect the distances of front obstacles Let s create a new project to read value from ultrasonic sensor Ultrasonic block can be founded in AlphaBot2 package Thi...

Page 68: ...ensor we can make Robot stop if there is obstacle in the front Robot keeps forward if the distance of obstacle in the front is longer than 15cm at the beginning and stop when the distance is less than...

Page 69: ...Alphabot2 for micro bit User Manual 69 76 CHAPTER 11 LINE TRACKING In the bottom side of Alphabot2 base board tracker sensor is integrated for tracking function...

Page 70: ...n Alphabot2 package SensorCalibrated block is used to calibrate the sensor for accurate Min and Max value AnalogRead block is used to read original data from infrared tacker sensor ReadCalibrated bloc...

Page 71: ...o read the five value there are five detectors and print it to set item to block can be founded in Variable serial write number and serial write string blocks can be founded in Advanced Serial item ge...

Page 72: ...serial software set baud rate to 115200 8N1 Data of sensors are printed to serial as below If you put the Alphabot2 on the air the output values are small about 0 10 If you put the robot to white grou...

Page 73: ...f black line Download the code to micro bit When black line is under the tracker sensor data are smaller to 80 100 The extreme right data is the position of black line Note that these data are not be...

Page 74: ...Alphabot2 for micro bit User Manual 74 76 CALIBRATED DATA We modify the last script to get calibrated data Download the script to micro bit...

Page 75: ...he calibrated data is outputted as below First line shows the max values of every sensor Second line shows the min values of every sensor Flowing the calibrated data For every line it shows the calibr...

Page 76: ...ate a new project to do the line tracking P is the tolerance of position positive robot deviation to right negative robot deviation to left D is the difference between current P and last P bigger the...

Reviews: