---
tags: 課程規劃
---
# 2022 05/28 澎湖 IOT 課程規劃
## 簡介
Odin 因為教授的詢問,能否到澎湖帶領科技(IOT)相關的工作坊,希望引導這些學生能夠
未來擁有運用科技解決所處環境問題的能力。
工作坊時間
20200528
一整天
工作坊地點
澎湖
工作坊對象
對科技有興趣的國中生與高中生
工作坊人數
30人
## 工作坊規劃
一天的工作坊時間,能夠陪伴學生學習的內容有限,所以透過這次機會能留下一些在工作坊結束後能夠持續發酵的資源是這次工作坊執行的方向之一。
就目前討論出能持續發酵的重點:
* 發現問題、提出解決計畫、計畫實踐的流程體驗
* 協助當地老師的資源共筆資訊
* 參與網路學習社群的禮儀與方法
* 伴伴學的線上共學經驗
等待定義的部分:
* 工作坊的地方議題
* 潮間帶偵測?
* 澎湖文化
* 材料選擇與準備
* 可以考慮用Kevin的板子
## 工作坊規劃與執行時間
* 三月份工作坊議題確認
* 四月份工作坊內容設計與測試
* 五月份軟硬體準備與授課
03/09 討論紀錄
* 嚐鮮
* 城市與電路探索
* 感應器
* 未來如何使用這些科技解決問題
需求:
需要公司的支援
講師支援,可以邀請工師內部的來自澎湖的工程師回鄉分享。
一個月去一次,一年後成果展。
05/09 討論紀錄
工作方當天的教學:
用 ameba 開發板控制一個舉旗小人,舉旗小人的動作是由兩顆 servo(伺服馬達) 來控制,完成動作後會發射一個紅外線訊號給另一個舉旗小人執行舉旗動作,完成後再發射紅外線訊號給另一個舉旗小人,以此類推。
學生課前準備:上課會使用到一些軟體,須事前安裝
徵求2-3位學生跟鄭工程師學習如何安裝,再協助同學安裝
鄭工程師的教學時間:一 ~ 五晚上8:00~10:00
請同學確認好共同時間,通知老師,屆時將使用 discord 線上授課,連結將在時間確認後提供。
安裝教學時間為 5/16(一) 晚上。
## 舉旗小人計畫
### 簡報
[紅外線互動舉旗小人](https://docs.google.com/presentation/d/1NwAoE6ToAtURjlEVwVbWN9_GbpQW6hDG6eInqeH5IB0/edit?usp=sharing)
### 所需硬體
* [[Ameba] A1 Lite / RTL8720DN (BW16) 開發板](https://www.makdev.net/2022/01/ameba-a1-lite-bw16-arduino-ide.html)
* servo sg 90 x2
* usb 線 x1
* 小型麵包板 x1
* 跳線一組 x1
* 小人模型 x1
* 所需電子零件:
* HX1838B 遙控器紅外線接收模組
* 感測器采用 HX1838B, 靈敏度高。
PCB 板尺寸:20x14mm
* 紅外線發射感測器模組
## 程式碼
```arduino=
#include "IRDevice.h"
#include <AmebaServo.h>
#define IR_RX_PIN PA26
#define IR_TX_PIN PA25
AmebaServo myservo01; //12
AmebaServo myservo02; //11
int pos01 = 0;
int pos02 = 0;
uint8_t adr = 0;//本地地址 讓學生改這個就好,(跑者背號)
uint8_t cmd = 0;//傳輸資料
uint8_t recvAdr = 0;//接收用的 儲存接收地址
uint8_t recvCmd = 0;//接收用的 儲存接收cmd
#define CARRIER_FREQ 38000
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
IR.beginNEC(IR_RX_PIN, IR_TX_PIN, IR_MODE_RX); // configure for NEC IR protocol
//IR.beginNEC(IR_RX_PIN, IR_TX_PIN, IR_MODE_TX); // configure for NEC IR protocol
myservo01.attach(PA13);
myservo02.attach(PA12);
}
void loop() {
if (IR.recvNEC(recvAdr, recvCmd, 1000)) {
Serial.print("i'm:");//沒收到任何資料
Serial.print(adr);//沒收到任何資料
Serial.print(",Received ");
Serial.print("recvAdr:");
Serial.print(recvAdr);
Serial.print("\t recvCmd:");
Serial.println(recvCmd);
if (recvAdr == adr) {
Serial.print("i'm:");
Serial.print(adr);
Serial.println("going next..");//沒收到任何資料
myservo01.write(90);
delay(1000);
myservo01.write(120);
delay(1000);
myservo02.write(90);
delay(1000);
myservo02.write(60);
delay(1000); //舉旗動作
recvAdr++;//把地址加一,假如本機為10,則則發送給11 對應第13行
IR.beginNEC(IR_RX_PIN, IR_TX_PIN, IR_MODE_TX); // configure for NEC IR protocol
delay(50);
IR.sendNEC(recvAdr, cmd);
IR.beginNEC(IR_RX_PIN, IR_TX_PIN, IR_MODE_RX); // configure for NEC IR protocol
delay(50);
}
} else {
Serial.print("i'm:");
Serial.print(adr);
Serial.println("and received nothing ");//沒收到任何資料
if (adr == 0) {//第一位跑者 編號為0
Serial.println("i'm 0 send to 1");
IR.beginNEC(IR_RX_PIN, IR_TX_PIN, IR_MODE_TX); // configure for NEC IR protocol
delay(50);
IR.sendNEC(1, cmd);
IR.beginNEC(IR_RX_PIN, IR_TX_PIN, IR_MODE_RX); // configure for NEC IR protocol
delay(50);
}
}
//IR.end(); // Call this method to stop IR device and free up the pins for other uses
}
```
https://www.amebaiot.com/en/amebad-arduino-irdevice/
### 函式庫
https://github.com/ambiot/amb1_arduino/tree/dev/Arduino_package/hardware/libraries/IRSendRecv
https://www.amebaiot.com/en/rtl8195-arduino-api-irsendrev/
[[Ameba] A1 Lite / RTL8720DN (BW16) 開發板 與 Arduino IDE](https://www.makdev.net/2022/01/ameba-a1-lite-bw16-arduino-ide.html)
教學
[IR - Transmit IR NEC Raw Data and Decode](https://www.amebaiot.com/en/amebad-arduino-irdevice/)
[EEVblog #506 - IR Remote Control Arduino Protocol Tutorial](https://youtu.be/BUvFGTxZBG8)
Arduino 練習:紅外線傳送與接收
[【IR #02】淺談紅外線遙控通訊協定 @Arduino @Matlab @Introduction](https://ruten-proteus.blogspot.com/2018/12/ir02-NEC-PhilipsRC6-protocol-introduction.html)