linkit one tutorial #1- basics

43
LinkIt ONE 物物物物物物

Upload: cavedu-education

Post on 13-Jan-2017

454 views

Category:

Devices & Hardware


7 download

TRANSCRIPT

Page 1: LinkIt ONE tutorial #1- Basics

LinkIt ONE 物聯網研習營

Page 2: LinkIt ONE tutorial #1- Basics

提供優質內容與服務

Page 3: LinkIt ONE tutorial #1- Basics

http://www.cavedu.com

Page 4: LinkIt ONE tutorial #1- Basics

Arduino Introduction• Massimo Banzi 和 David Cuartielles 所設計• 採用低價位微處理器, Atmel Atmega8/168/328 單晶片• 開放式的軟硬體平台• 於教育與非工業市場大受歡迎

Page 5: LinkIt ONE tutorial #1- Basics
Page 6: LinkIt ONE tutorial #1- Basics

LinkIt ONE 正面

Micro USB

電池接口

Digital(PWM~ )Pin13 / Power LED

Reset 類比輸入電壓 in/out

Audio in /out

Page 7: LinkIt ONE tutorial #1- Basics

LinkIt ONE 背面SD/ Sim

GSM 天線

Wifi/BT 天線

GPS 天線

Page 8: LinkIt ONE tutorial #1- Basics

Wifi / Bluetooth 二合一天線

Page 9: LinkIt ONE tutorial #1- Basics

GPS 天線

Page 10: LinkIt ONE tutorial #1- Basics

GPRS 天線• 行動上網需搭配 SIM 卡 ( 不可上鎖 )

Page 11: LinkIt ONE tutorial #1- Basics

可充電鋰電池 ( 透過板子充電 )

Page 13: LinkIt ONE tutorial #1- Basics

安裝開發環境Arduino IDE + LinkIt ONE SDK

Page 15: LinkIt ONE tutorial #1- Basics

下載之後解壓縮放到 C: 下即可• 重要資料夾:– /libraries :函式庫– /drivers :驅動程式– /examples :範例

Page 17: LinkIt ONE tutorial #1- Basics

下載 1.1 SDK

Page 18: LinkIt ONE tutorial #1- Basics

安裝時需指定 Arduino IDE 路徑

Page 19: LinkIt ONE tutorial #1- Basics

打開裝置管理員,檢查埠號

Page 20: LinkIt ONE tutorial #1- Basics

最後請安裝 USB driver• 安裝完成後插上板子應該就可以自動裝好

Page 21: LinkIt ONE tutorial #1- Basics

或是手動指定也可以• C:\Arduino\drivers\mtk 指定到這

Page 22: LinkIt ONE tutorial #1- Basics

Alcatel RNDIS problem• 請重新安裝 LinkIt SDK ,並取消 Windows update

Page 23: LinkIt ONE tutorial #1- Basics

相關函式庫在這• C:\Arduino\hardware\arduino\mtk

Page 24: LinkIt ONE tutorial #1- Basics

LinkIt ONE 會有兩個 COM port

• MTK USB Debug port :下載程式用• MTK USB Modem port :使用 Serial

Monitor

Page 25: LinkIt ONE tutorial #1- Basics

設定板子: Tools/Board/LinkIt ONE

Page 26: LinkIt ONE tutorial #1- Basics

設定埠號:• 需選定 Debug Port (19) 才能下載程式

Page 27: LinkIt ONE tutorial #1- Basics

範例 1 : LED 亮滅• File >> Examples >> 1.Basics >> Blink

Page 28: LinkIt ONE tutorial #1- Basics

LED Blink• Verify & Upload

VerifyUpload

Status

Page 29: LinkIt ONE tutorial #1- Basics

執行時須注意Pin13 LED 會每秒亮滅

切到 UART

切到 SPI

Page 30: LinkIt ONE tutorial #1- Basics

How does it work?void setup() { 初始化

}void loop() { 重複執行...}

Page 31: LinkIt ONE tutorial #1- Basics

How does it work?int led = 13;

void setup() { pinMode(13, OUTPUT); // 設定 #13 腳位為輸出模式

}

void loop() { digitalWrite(led, HIGH); // 設定本腳位高電位, LED 亮 delay(1000); // 等候 1 秒 digitalWrite(led, LOW); // 設定本腳位低電位, LED 滅 delay(1000); }

Page 32: LinkIt ONE tutorial #1- Basics

小挑戰:請改到 pin 9

Page 33: LinkIt ONE tutorial #1- Basics

範例 2 : LED 呼吸燈(File >> Example >> Basic >> Fade)

Page 34: LinkIt ONE tutorial #1- Basics

程式int brightness = 0; // how bright the LED isint fadeAmount = 5; // how many points to fade the LED byvoid setup() { // declare pin 9 to be an output: pinMode(9, OUTPUT);} void loop() { // set the brightness of pin 9: analogWrite(9, brightness); // change the brightness for next time through the loop: brightness = brightness + fadeAmount; // reverse the direction of the fading at the ends of the fade:

if (brightness == 0 || brightness == 255){

fadeAmount = -fadeAmount ; } // wait for 30 milliseconds to see

the dimming effect delay(30);

}

Page 35: LinkIt ONE tutorial #1- Basics

可變電阻

Page 36: LinkIt ONE tutorial #1- Basics

接線• 中間: A0• 一側: 5V• 另一側: GND

Page 37: LinkIt ONE tutorial #1- Basics

讀取類比腳位狀態 (File >> Example >> Basic>> AnalogReadSerial)

void setup() {  Serial.begin(9600);}

void loop() {  int sensorValue = analogRead(A0);    Serial.println(sensorValue);  delay(1);        } 記得切到 Modem port !!

Page 38: LinkIt ONE tutorial #1- Basics

可變電阻控制 LED 漸明漸暗(File >> Example >> Analog >> AnalogInOutSerial)

Page 39: LinkIt ONE tutorial #1- Basics

光敏電阻• 一端接 A0 ,一端接地• 由於是被動元件,需要在 A0 那端加上 5V

Page 40: LinkIt ONE tutorial #1- Basics

電路示意圖

Page 41: LinkIt ONE tutorial #1- Basics

Fritzing 電路繪製軟體

元件內容

元件庫繪圖區

Page 42: LinkIt ONE tutorial #1- Basics

123D circuits由 AutoDesk 公司推出的線上電路模擬軟體

Page 43: LinkIt ONE tutorial #1- Basics

更新 LinkIt ONE 韌體• C:\Arduino\hardware\tools\mtk