การเรียนเขียนโปรแกรมภาษาใหม่ ๆ ต้องใช้เวลามากพอสมควร การลดระยะเวลาของการทำความเข้าใจ จึงเป็นการเพิ่มประสิทธิภาพของการเรียนรู้ ดังนั้นระบบใหม่ ๆ หรือภาษาใหม่ มักจะมีการทำ Tutorials ออกมาเพื่ออำนวยความสะดวกและเพิ่มประสิทธิภาพการเรียนรู้สำหรับผู้เริ่มต้นเขียนโปรแกรม โดย Tutorial ส่วนมากจะเป็น tutorial ที่มีคุณภาพ ดังนั้นการศึกษาจาก Tutorial นั้น ถือว่าเป็นวิธีการเรียนรู้อย่างฉลาดวิธีหนึ่ง
👻 ในคาบเรียนนี้ เราจะมาท่อง Tutorials กัน โดยจะให้นักเรียนทำกิจกรรมอย่างน้อย 4 กิจกรรม
เข้าในห้องนี้เลยครับ https://makecode.microbit.org/
Flashing Heart
1. Click on the Basic category in the Toolbox. Drag the show leds block into the forever block. Then in the show leds block, click one the squares to draw a heart design.
2. Drag another show leds block underneath the first.
3. Look at the micro:bit on the screen. Do you see a flashing heart animation? ⭐Great job!⭐
Name Tag
See your name in 💡 lights! 💡 Code the micro:bit to scroll your name across the screen.
1. Click on the Basic category in the Toolbox. Drag the show string block into the forever block. Then in the show string block, change the text from "Hello!" to your name.
2. Look at the micro:bit on the screen. Do you see your name scrolling across? ⭐Great job!⭐ You've turned the micro:bit into a digital name tag!
3. If you have a micro:bit device, connect it to your computer and click the Download button. Follow the instructions to transfer your code onto the micro:bit and watch your name appear in lights!
4. Go further - try adding more show string blocks to create a story!
Smiley Buttons
Let's show a happy face when we press button A.
1. Click on the Basic category in the Toolbox. Drag a show icon block into the on button A pressed block. In the show icon block, Click on the Heart icon to open the menu. Select a Happy Face icon.
2. In the micro:bit simulator on the screen, press the A button. Do you see a happy face? ⭐ Great job! ⭐
-----------------------------------------------------------------------------
Now let's show a sad face when we press button B.
3. Click on the Input category in the Toolbox. Drag another one button A pressed block onto the coding workspace (you can place the anywhere). Click on the A Button drop-down menu, and select B.
4. From the Basic category, drag another show icon block into the on button B pressed block. In this show icon block, click on the Heart icon to open the menu. Select a Sad Face icon.
5. In the micro:bit simulator on the screen, press the B button. Do you see a sad face? ⭐ Great job! ⭐
Dice
Let's create some digital 🎲 dice 🎲 with or micro:bit!
1. The on shake block runs code when you shake 👋 the micro:bit. From the Basic category, get a show number block and place it inside the on shake block to display a number.
2. Press the white SHAKE button on the micro:bit on-screen simulator, or move your cursor quickly back and forth over the simulator. Do you see the number 0 appear? ⭐Great job!⭐
3. But we don't want to show 0 on our dice all the time. From the Math Toolbox category, drag a pick random block and drop it into the show number block replacing the 0.
4. A typical dice show values from 1 to 6 dots. So, int the pick random block, change the minimum value to 1 and the maximum value to 6.
5. Press the white SHAKE button again on the micro:bit simulator. Do you see random numbers between 1 and 6 appear? ⭐Great job!⭐
6. If you have a micro:bit device, connect it to your computer and click the Download button. Foolow the instructions to transfer your code onto the micro:bit. Once your code has been downloaded, attach your micro:bit to battery pack and use it as digital 🎲 dice for your next boardgame!
Love Meter
How much love 😍 are you emitting to day? Create a ❤️ LOVE METER ❤️ machine with your micro:bit!
1.We'll use this 🔴 on pin pressed block to run code when pin 0 on the micro:bit is pressed. From the 🟦 Basic Toolbox category, drag a 🟦 show number block and drop into the 🔴on pin pressed block.
2. From the 🟦 Math category, get a pick random block and drop it into the show number block replacing 0.
3. Now let's be sure to label our Love Machine! From the 🟦 Basic Toolbox category, drag an 🟦 on start block and drop it anywhere on the Workspace. Then get a 🟦 show string block and place it in the 🟦 on start block. Type the words "LOVE METER" into the 🟦 show string block.
4. Let's test our code. Press Pin 0 on the micro:bit one-screen simulator (bottom left). Numbers between 0-25 = No Love, 26-50 = BFF Love, 51-75 = Brokenhearted Love, 76-100 = Fiery Hot Love!
5. If you have a micro:bit device, connect it to your computer and click the Download button. Follow the instructions to transfer your code onto the micro:bit. Once your code has been downloaded, hold the GND pin with one hand and touch the 0 pin with the other hand. Your micro:bit ❤️ LOVE METER ❤️ machine will detect the love current flowing through your body!
Micro Chat
Use the micro:bit 📻 radio to send and receive 💬 massages between micro:bits!
1. From the 📶 radio Toolbox category, drag a 📶 radio set group block into the on start block. This will act as the channel over which we'll send messages. Only micro:bits who are in the group will be able to send and receive messages between them.
2. From the Input Toolbox category, drag an on button A pressed block onto the Workspace.
3. From the 📶 radio category, drag a 📶 radio send string block into the on button A pressed block and type a message. When we press button A on our micro:bit, we'll send the message to every micro:bit nearby in group 1.
4. From the 📶 radio category, drag an 📶 on radio received string block onto the Workspace.
5. Form the Basic category, get a show string block and drop it in the on radio received string block.
6. Pull the receivedString variable block out of the on received string block and put it into the show string block replacing "Hello!"
7. Let's test our code! In the micro:bit on-screen simulator, press button A. You should see a second micro:bit appear. Now try pressing A again. Do you see your message appear on the second micro:bit? ⭐Great job!⭐
8. If you have a micro:bit device, connect it to your computer and click the Download button. Follow the instructions to transfer your code onto the micro:bit. If you have two micro:bits, download the program to each one. Press button A on one and see if the other gets the message!
9. Go further - try using different buttons to send a mix of messages 📄, or send secret 🔒 messages to different radio groups!