發表文章

目前顯示的是 11月, 2020的文章

Solution to Karel Coding – Hour of Code

圖片
If you like this post, please click the ads on the blog or  buy me a coffee . Thank you very much. Here comes the possible solutions to Karel Coding: Hour of Code  https://hoc.nclab.com/karel/ Level 1 Level 2 Level 3 Level 4 Level 5 Level 6 Level 7 Level 8 Level 9 Level 10 Level 11 Level 12 Level 13 Level 14 Level 15

MakeCode Microbit 遙控機器人 (Microbit Remote-Controlled Robot)

圖片
若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。 If you like this post, please click the ads on the blog or  buy me a coffee . Thank you very much. 本篇文章將講解如何製作一個簡易的遙控機器人,此篇文章所使用的機器人為【 麥昆智能小車 (Maqueen) 】。This post will build a simple remote car with Maqueen which is a micro:bit based robot platform for education. 一、功能如下(Game Design):   訊號說明(The communication way): 使用英文字母f、b、l、r、s 五個字母,對應動作為:f 為前進、b 為後退、l 為左轉、r 為右轉、s 為停止。Using the first letter of each action: f orward, b ackward, l eft, r ight, s top. That is, the letter f stands for forward. The letter b stands for backward, and so on.  遙控器(The controller) 按下 A + B 按鈕時,送出停止(stop)訊號。Sending a s top signal when button A and B are pressed. Microbit 板子向上傾斜時,送出前進f(forward)訊號。Sending a f orward signal when tilting the microbit front. Microbit 板子向下傾斜時,送出後退b(backward)訊號。Sending a  b ackward signal when tilting the microbit back. Microbit 板子向左傾斜時,送出左轉l(left)訊號。Sending a  l eft signal when tilting the microbit to the left. Microbit 板子向右傾斜時,...

bDesigner 與 Arduino 互動

圖片
若您覺得文章寫得不錯,請點選網誌上的廣告,來支持小編,謝謝。 bDesigner 簡短介紹 bDesigner 是由桃園市八德國小 蔡佳倫老師 自行研發之Scratch擴充積木軟體以及blockly程式。在他的  Youtube 上也有很多的教學影片。除了可以使用 Scratch 3 以外,還可與多種硬體(如Arduino UNO、Nano、ESP32、Microbit等)互動,使用這一套就可以省去了一直安裝不同軟體的時間,非常適合接觸多種硬體與blockly程式教學的老師們。 底下為筆者使用 bDesigner 與 Arduino UNO、Nano 的筆記紀錄。 與 Arduino Nano 互動 步驟一:燒錄 以MiniUSB 將 Nano 連接到電腦上,開啟 bDesigner,點選上方選單的 燒錄 --> 開啟燒錄程式 。 選擇板子 Arduino Nano 與 COM編號 (請讀者根據自己電腦上的編號做選擇),按下 燒錄 。 此時會出現燒錄的畫面。 完成後,請關閉燒錄程式視窗。 步驟二:開啟 Scratch 3 軟體點選 Scratch 3 ,積木類型選 USB連多個 Arduino 。 步驟三:添加 Scratch 3擴展 點選 Scratch 3 左下方的擴展圖示 ,選擇bDesigner(Arduino)擴展 步驟四:設計 Arduino 內建 LED閃爍積木程式 設計如下的積木程式: 此時,按下綠旗,就可以看到 Nano 板子上標示 L 的 LED 燈閃爍三次(下圖紅色矩形的LED燈) 與 Arduino UNO 互動 此部分除了在燒錄時,需選擇板子 Arduino UNO外,其餘步驟和  與 Arduino Nano 互動 一樣。 那要如何讓 Arduino 自行運作(不需要電腦的離機模式)呢?

MakeCode Microbit 遊戲設計:貓追老鼠遊戲(Microbit Game: Cat Chasing Mouse Game)

圖片
若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。 If you like this post, please click the ads on the blog or  buy me a coffee . Thank you very much. 本篇文章將講解如何製作一個簡易追逐遊戲:【貓追老鼠】。 In this post, we're going to create a a simple chasing game: "cat chasing mouse", where you tilt the microbit to control a cat which is chasing a blinking mouse on the LED screen. 一、遊戲功能如下(Game Design):   遊戲時間一分鐘。One minute game. 遊戲開始時,貓在畫面正中央。The cat is at the screen center when the game on start. 老鼠不停閃爍,老鼠跑到隨機位置。The mouse is blinking and at random position on the screen. 板子往上傾斜時,貓往上移動。The cat move up when tilting the microbit front. 板子往下傾斜時,貓往下移動。The cat move down when tilting the microbit back. 板子往右傾斜時,貓往右移動。The cat move to right when tilting the microbit to the right. 板子往左傾斜時,貓往左移動。The cat move to left when tilting the microbit to the left. 貓捉到老鼠時,得一分,老鼠跑到隨機位置。 When the cat catches the mouse, the mouse runs to random position. The player scores 1 point. 二、積木程式(Blocks Code) 遊戲時間一分鐘。One minute game. 遊戲開始時,貓在畫面正中央。T...

C語言練習題:陣列(C language exercise: Array)

圖片
若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。 If you like this post, please click the ads on the blog or  buy me a coffee . Thank you very much. 練習一:整數陣列加總 使用一個大小為10的整數陣列來讀取使用者所輸入的10個整數,並算出此十個整數的總和。 Exercise 1: Sum of an array of integer Using an integer array of size 10 to store input from user. Now print the sum of these 10 integers. 練習一參考解法: Exercise 1 solution: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include <stdio.h> #include <stdlib.h> int main () { int numbers[ 10 ], sum = 0 ; for ( int i = 0 ; i < 10 ; i ++ ) { printf( "Enter an integer for numbers[%d]:" , i); scanf( "%d" , & numbers[i]); sum = sum + numbers[i]; } printf( " \n Sum:%d" , sum); return 0 ; } 練習二:整數陣列中最大的整數 使用 亂數函數 rand()  產生 10 整數,並找出最大值。 Exercise 2: Find the largest integer Using rand()  function to generate 10 integers and find the biggest integer. 練習二參考解法: Exercise 2 solution: 1 2 3 4 5 6 7 8 ...