『彈指玩轉世界』專書發表暨程式教育論壇(1060314)

日期:106年3月14日

地點:新北市政府大樓6樓大禮堂。

活動內容:

9:30-10:00 報到(發送參與人員專書1本)。
10:00-10:40 揭書儀式、播放程式教育影片、長官貴賓參觀主題展區。
10:40-11:10 專題演講。
11:10-12:00 程式教育分享會(沙龍座談)。
12:00-13:00 參觀主題展區。【會後發贈餐盒】

參考資料:

相關連結:

活動照片:(摘錄自彭于佳、黃保太、呂天齡的Facebook)

106年第一次校園網站維運會議(1060313)

日期:106年3月13日(一)

時間:10:30~12:00

列席人員:所有行政人員及各學年主任。

工作報告:

Synology NAS 網站維運(1060308)

Synology NAS Server 系統更新:

版本: 6.1-15047-1

(2017/02/25)

  1. 修正一項與「自動封鎖」功能有關的安全性漏洞,該漏洞可允許遠端的攻擊者略過目前的 IP 封鎖機制。

[網路中斷通知]3/13(一) 22:00 ~ 3/14(二) 06:00(1060308)

新北市教育網路中斷通知

3/13(一) 22:00 ~ 3/14(二) 06:00 科技大樓原國網中心電力線路移轉。

台北區網2(政治大學)與 Hinet Peering 互連服務中斷。

新北市教育網影響範圍:

施工期間3/13(一) 22:00 ~ 3/14(二) 06:00:

由學校內連接教育局所有服務及市府公文系統正常,

學校對政大出口至internet連線將發生異常。

 

李煒

80723456-517

新北市程式開發社群工作坊-Scratch擴充積木設計(1060308、0315、0322)

日期:106年3月8日、3月15日、3月22日

地點:新北市教研中心

講師:蔡佳倫老師

三周的課程如下:
—————————————————————-
3/8 第一節課會先講語言的轉換
3/15 第二節講講mblock的積木撰寫
3/22 第三節會講python跟scratch
—————————————————————-

設備使用 Arduino模擬器 和 S2A,不用準備硬體!

課程內容:

Scratch 擴充積木設計:

教學範例:

base_helper.s2e


{

“extensionName": " 自訂積木 “,
“extensionPort": 50000,
“blockSpecs": [
[“r", “資料", “hello"],
[“r", “資料1″, “hello1″],
]

}


用Python擴充我的Scratch2 — 原理與Hello World篇

base_helper_py3.py


def do_GET(self):

  try:

 """
 process HTTP GET requests
 """
# skip over the first / . example: /poll -> poll 
 cmd = self.path[1:]
 # create a command list . 
 cmd_list = cmd.split('/')
 
 s = "不回傳資料"
 ###### 處理Scratch送出的命令
 ###### 若需回應Scratch的Poll命令,再把文字存在變數s ##
 ##############################################################
 
 crlf = "\r\n"
 if cmd_list[0] == "poll":
 s="hello " + "hello" + crlf
 s+="hello1 " + "hello1" + crlf
 
 #############################################################

except:

s = “不回傳資料"

finally:

self.send_resp(s)


Creating Scratch 2.0 Extensions 摘要說明:

Block description

Each block is described by an array with the following fields:

  • block type
  • block format
  • operation or remote variable name
  • (optional) zero or more default parameter values

The block type is one of these strings:

  • " " – command block
  • “w" – command block that waits
  • “r" – number reporter block (round ends) ==> 前面有帶一個 checkbox
  • “b" – boolean reporter block (pointy ends)
  • “R" – Reporters that wait (round ends)

The block format is a string that describes the labels and parameter slots that appear on the block. Parameter slots are indicated by a word starting with “%" and can be one of:

  • %n – number parameter (round ends)
  • %s – string parameter (square ends)
  • %b – boolean parameter (pointy ends)

Menu parameters

Both command and reporter blocks can include menu parameters:

  • %m.menuName – menu parameter (not editable)
  • %d.menuName – editable number parameter with menu
{ 
  "extensionName": "Kinect",
  "extensionPort": 12345,
  "blockSpecs": [ 
    ["r", "get %m.coordinate position of %m.bodyPart", "position"],
  ], 
  "menus": { 
    "coordinate": ["x", "y", "z"],
    "bodyPart": ["head", "shoulder", "elbow", "hand"],
  },
}

position/y/hand 247 => 回傳值為 247 (鍵、值用空格分隔)

Polling (每秒 30 次)

Scratch to retrieves sensor values and status information from the helper app by sending a poll command:

request: /poll

Here’s an example poll response:

response: 鍵、值用空格分隔,每一筆資料用 crlf (\r\n) 分隔

brightness 75 + crlf (\r\n)
slider 17 + crlf (\r\n)

Commands

/beep                    (command with no parameters)
/setVolume/5   (command with a numeric parameter)

Commands that wait

turn motor on for 3 seconds

turns on the motor, waits three seconds, then turns it off again. When this block is used in a script, execution does not continue to the next block until the command completes. A command that waits is indicated by the “w" block type in the command descriptor.

When a “w" command is invoked, Scratch adds a unique command_id parameter to the request (before any other parameters). For example, for the motor command above Scratch would send:

request:     /motorOn/2437/3

The first parameter, 2437, is a unique identifier for this invocation of the command. For the three seconds that this command takes to complete, the helper app adds a busy line to the poll request:

response:  _busy 2437 …

A busy line consists of the string “_busy" followed by a list of unique identifiers separated by spaces. When Scratch gets a poll result that doesn’t include 2437 in the busy line (or doesn’t even have a busy line), it knows that the command is complete and allows the script that invoked that command to proceed.

Reporters that wait (目前已實作出來) => “R"

temperature in city_name

request:     /getTemperature/7639/Boston

response:  _result 7639 82

Reset command

Scratch extensions can control motors or music synthesizers. Users expect to be able to stop everything — turn off motors, silence music synthesizers, and reset hardware back to it’s original state — by clicking the stop button in the Scratch editor. Thus, when the stop button is clicked, Scratch sends a reset command to all active extensions:

request: /reset_all


參考資料與範例:

mBlock 擴充積木設計:

mBlock 積木程式轉Arduino 程式教學:

範例一:

Autodesk 123D circuits 繪圖

mBlock 積木程式:

Arduino 程式

#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>

double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
double switchStatus;

void setup(){
Serial.begin(9600); //改成9600,才能於123D中執行
pinMode(2,INPUT);
}

void loop(){
switchStatus = digitalRead(2);
Serial.println(switchStatus);
_loop();
}

void _delay(float seconds){
long endTime = millis() + seconds * 1000;
while(millis() < endTime)_loop();
}

範例二:

Autodesk 123D circuits 繪圖

mBlock 積木程式:

Arduino 程式

#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>

double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
double Button;
double LED;

void setup(){
    Button = 2;
    LED = 12;
    pinMode(Button,INPUT);
    pinMode(LED,OUTPUT);
}

void loop(){
    if(((digitalRead(Button))==(1))){
        digitalWrite(LED,1);
    }else{
        digitalWrite(LED,0);
    }
    _loop();
}

void _delay(float seconds){
    long endTime = millis() + seconds * 1000;
    while(millis() < endTime)_loop();
}

void _loop(){
}

參考資料:

BlocklyDesigner 安裝教學:

蔡佳倫教學影片:

活動照片: