Lesson 1: Setup/Micro Chat Radio/LED Lights
Objectives
- Introduce the students to the Micro:Bit controller and its potential capabilities.
- Helping the students connect their controller to their laptop.
- Explaining to the students what an LED is.
- Teaching the students how to use the Micro:Bit to draw patterns using the LED array on their boards and MakeCode.
- Understand that the Micro:Bit has a radio component that we can use to communicate between boards.
Preparation For Instructors
- Everyone will need a Micro:Bit Controller, micro-USB cable, and a ShareMyWorks account.
- Print out copies of the syllabus and homework.
- Everyone will access this website to use the MakeCode https://makecode.microbit.org/
- Be familiar with MakeCode and the Micro:Bit.
- Understand the blocks associated with the radio.
Class Schedule/Tasks:
Setup:
- Students should plug in their Micro:Bit controller into their laptops using the micro USB cable and open the MakeCode website:
- Help students create a Share My Works account if they do not already have one.
- Explain to the students that the Micro:Bit is basically a mini computer to run their code.
Micro Chat Radio:
You can use this MakeCode link to view the code: https://makecode.microbit.org/_eMk9Vdezy5rp
- Tell students that we are moving onto radios that can send signals between boards. This allows boards to interact with each other. There is a hardware part labeled BLE Antenna on the back of the board.
- Split the students up into pairs so they can interact with each others boards without interfering with other students. If there is an odd number of students, one of the students can pair up with the instructor.
- Assign each group a group number. Have students pull the radio set group __ into the on start block and place their group number in the blank spot. Each groups radios will only transmit and receive messages from Micro:Bits with their group number.
- Show students where the radio send string __ block is in the Radio category of blocks. Have students try on their own to have a specific message sent upon button presses.
- Explain to students that sending is not enough, the board must be able to receive an input and know what to do with it.
- Show students the on radio received receivedString block in the radio category and explain that to see the message sent, they must be able to display it.
- Students should combine the on radio received receivedString block with the show string ___ block to display the string they recieve. The receivedString variable must be dragged out of the on radio received receivedString block. There is no other way to grab it.
- Switch to JavaScript and go over the basic structure of this. Have students try and modify what strings they are sending on the inputs.
- Have students slowly back away from each other and send strings to allow them to test how far away the range of the radio goes. Show them that we can manipulate the power using the Radio set transmit power_ block in the extra options of the radio. It goes from 0-7, 7 can reach as far as 70 meters.
- Have students implement 2 more options on their own. Remind them that they are able to use the A+B and On Shake inputs.
- Have students upload their projects onto ShareMyWorks.
LED Lights and Patterns:
You can use this MakeCode link to view the code: https://makecode.microbit.org/_TXz6tk72uakM
- Before starting a new project, have students examine their board and notice the LEDs placed on the controller.
- Explain to them that LEDs work by flowing electricity. The energy from electricity gets lost as it travels through the circuit and is converted into light.
- Bring it back to the Micro:Controller by explaining how there are 25 LEDs placed in an array grid. With the processor on the back, we can control the LEDs using code.
- Tell the students that we will be using the LEDs to create a pattern on the board.
- Have the students open a new project. On this page, there will be 2 blocks, on start, and forever.
- Explain to the students that with on start, the block will only execute once whereas with forever, the block will continuously loop through whatever is put in.
- Show the students the difference between on start and forever by placing a show leds block on each of them and running to different patterns. Also use this to show students how they can draw different patterns using the LEDs.
- Ask students which block they would use to have a pattern of a heart show forever. Assist the students in creating and running the code
- Ask students how they would switch between 2 patterns constantly. Introduce to them the idea of stringing multiple blocks together to create something more.
- Have students switch between a heart and smiley face, or pattern of their choosing.
- Show students the JavaScript equivalent. Have students change the code to draw out their own patterns using JavaScript. Take note of the single quotations before the patterns are drawn.
- Now that students have an understanding of the commands, have each student spell their name out on the board. If their name is too long or too short, perhaps provide them with a different word to spell.
- Have students register for Sharemyworks.com. A few usernames may not work, just keep changing it until it does. The email portion is optional as some students may not have an email yet.
- Download and publish the project and show students how to upload their work onto Sharemywork.com.