Submit Search
Upload
Arduino 習作工坊 - Lesson 4 通訊之夜
•
9 likes
•
33,719 views
CAVEDU Education
Follow
教您如何使用Android 手機透過藍牙與 Arduino 溝通。可以控制 Arduino 的輸出還能把 Arduino 的狀態顯示在畫面上。
Read less
Read more
Devices & Hardware
Report
Share
Report
Share
1 of 62
Download now
Download to read offline
Recommended
HC 05藍芽模組連線
HC 05藍芽模組連線
Chen-Hung Hu
Arduino藍牙傳輸應用
Arduino藍牙傳輸應用
吳錫修 (ShyiShiou Wu)
Arduino序列通訊應用
Arduino序列通訊應用
吳錫修 (ShyiShiou Wu)
mBot教學(1) - mBot初體驗
mBot教學(1) - mBot初體驗
吳錫修 (ShyiShiou Wu)
Arduino感測應用
Arduino感測應用
吳錫修 (ShyiShiou Wu)
micro:bit LED顯示控制
micro:bit LED顯示控制
吳錫修 (ShyiShiou Wu)
Arduino簡介
Arduino簡介
吳錫修 (ShyiShiou Wu)
Python程式設計 - 分支作業
Python程式設計 - 分支作業
吳錫修 (ShyiShiou Wu)
Recommended
HC 05藍芽模組連線
HC 05藍芽模組連線
Chen-Hung Hu
Arduino藍牙傳輸應用
Arduino藍牙傳輸應用
吳錫修 (ShyiShiou Wu)
Arduino序列通訊應用
Arduino序列通訊應用
吳錫修 (ShyiShiou Wu)
mBot教學(1) - mBot初體驗
mBot教學(1) - mBot初體驗
吳錫修 (ShyiShiou Wu)
Arduino感測應用
Arduino感測應用
吳錫修 (ShyiShiou Wu)
micro:bit LED顯示控制
micro:bit LED顯示控制
吳錫修 (ShyiShiou Wu)
Arduino簡介
Arduino簡介
吳錫修 (ShyiShiou Wu)
Python程式設計 - 分支作業
Python程式設計 - 分支作業
吳錫修 (ShyiShiou Wu)
Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得
roboard
射頻電子實驗手冊 [實驗1 ~ 5] ADS入門, 傳輸線模擬, 直流模擬, 暫態模擬, 交流模擬
射頻電子實驗手冊 [實驗1 ~ 5] ADS入門, 傳輸線模擬, 直流模擬, 暫態模擬, 交流模擬
Simen Li
Verilog 語法教學
Verilog 語法教學
艾鍗科技
機器人齊步走 mBlock5 mbot_ver8_探奇邱信仁
機器人齊步走 mBlock5 mbot_ver8_探奇邱信仁
信仁 邱
Arduino程式除錯
Arduino程式除錯
吳錫修 (ShyiShiou Wu)
mbot2.0教學-使用makeblock雲服務.pdf
mbot2.0教學-使用makeblock雲服務.pdf
吳錫修 (ShyiShiou Wu)
Vlsi design-manual
Vlsi design-manual
Ambuj Jha
射頻電子 - [實驗第一章] 基頻放大器設計
射頻電子 - [實驗第一章] 基頻放大器設計
Simen Li
mBot 教學10 藍牙控制應用
mBot 教學10 藍牙控制應用
吳錫修 (ShyiShiou Wu)
射頻電子實驗手冊 - [實驗7] 射頻放大器模擬
射頻電子實驗手冊 - [實驗7] 射頻放大器模擬
Simen Li
Microbit 1 introduction
Microbit 1 introduction
吳錫修 (ShyiShiou Wu)
mBot 教學2 mBlock積木式設計程式
mBot 教學2 mBlock積木式設計程式
吳錫修 (ShyiShiou Wu)
Agilent ADS 模擬手冊 [實習1] 基本操作與射頻放大器設計
Agilent ADS 模擬手冊 [實習1] 基本操作與射頻放大器設計
Simen Li
教學(10)藍牙控制應用
教學(10)藍牙控制應用
吳錫修 (ShyiShiou Wu)
Python與Ardinio整合應用
Python與Ardinio整合應用
吳錫修 (ShyiShiou Wu)
射頻電子實驗手冊 - [實驗8] 低雜訊放大器模擬
射頻電子實驗手冊 - [實驗8] 低雜訊放大器模擬
Simen Li
移植FreeRTOS 之嵌入式軟體研究與開發
移植FreeRTOS 之嵌入式軟體研究與開發
艾鍗科技
期末專題報告書
期末專題報告書
HsuChi Chen
mBot教學(4) - 移動控制
mBot教學(4) - 移動控制
吳錫修 (ShyiShiou Wu)
射頻電子 - [實驗第二章] I/O電路設計
射頻電子 - [實驗第二章] I/O電路設計
Simen Li
認識 RoBoard 硬體
認識 RoBoard 硬體
roboard
Arduino Basic
Arduino Basic
mmiwwcom
More Related Content
What's hot
Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得
roboard
射頻電子實驗手冊 [實驗1 ~ 5] ADS入門, 傳輸線模擬, 直流模擬, 暫態模擬, 交流模擬
射頻電子實驗手冊 [實驗1 ~ 5] ADS入門, 傳輸線模擬, 直流模擬, 暫態模擬, 交流模擬
Simen Li
Verilog 語法教學
Verilog 語法教學
艾鍗科技
機器人齊步走 mBlock5 mbot_ver8_探奇邱信仁
機器人齊步走 mBlock5 mbot_ver8_探奇邱信仁
信仁 邱
Arduino程式除錯
Arduino程式除錯
吳錫修 (ShyiShiou Wu)
mbot2.0教學-使用makeblock雲服務.pdf
mbot2.0教學-使用makeblock雲服務.pdf
吳錫修 (ShyiShiou Wu)
Vlsi design-manual
Vlsi design-manual
Ambuj Jha
射頻電子 - [實驗第一章] 基頻放大器設計
射頻電子 - [實驗第一章] 基頻放大器設計
Simen Li
mBot 教學10 藍牙控制應用
mBot 教學10 藍牙控制應用
吳錫修 (ShyiShiou Wu)
射頻電子實驗手冊 - [實驗7] 射頻放大器模擬
射頻電子實驗手冊 - [實驗7] 射頻放大器模擬
Simen Li
Microbit 1 introduction
Microbit 1 introduction
吳錫修 (ShyiShiou Wu)
mBot 教學2 mBlock積木式設計程式
mBot 教學2 mBlock積木式設計程式
吳錫修 (ShyiShiou Wu)
Agilent ADS 模擬手冊 [實習1] 基本操作與射頻放大器設計
Agilent ADS 模擬手冊 [實習1] 基本操作與射頻放大器設計
Simen Li
教學(10)藍牙控制應用
教學(10)藍牙控制應用
吳錫修 (ShyiShiou Wu)
Python與Ardinio整合應用
Python與Ardinio整合應用
吳錫修 (ShyiShiou Wu)
射頻電子實驗手冊 - [實驗8] 低雜訊放大器模擬
射頻電子實驗手冊 - [實驗8] 低雜訊放大器模擬
Simen Li
移植FreeRTOS 之嵌入式軟體研究與開發
移植FreeRTOS 之嵌入式軟體研究與開發
艾鍗科技
期末專題報告書
期末專題報告書
HsuChi Chen
mBot教學(4) - 移動控制
mBot教學(4) - 移動控制
吳錫修 (ShyiShiou Wu)
射頻電子 - [實驗第二章] I/O電路設計
射頻電子 - [實驗第二章] I/O電路設計
Simen Li
What's hot
(20)
Arduino 底層原始碼解析心得
Arduino 底層原始碼解析心得
射頻電子實驗手冊 [實驗1 ~ 5] ADS入門, 傳輸線模擬, 直流模擬, 暫態模擬, 交流模擬
射頻電子實驗手冊 [實驗1 ~ 5] ADS入門, 傳輸線模擬, 直流模擬, 暫態模擬, 交流模擬
Verilog 語法教學
Verilog 語法教學
機器人齊步走 mBlock5 mbot_ver8_探奇邱信仁
機器人齊步走 mBlock5 mbot_ver8_探奇邱信仁
Arduino程式除錯
Arduino程式除錯
mbot2.0教學-使用makeblock雲服務.pdf
mbot2.0教學-使用makeblock雲服務.pdf
Vlsi design-manual
Vlsi design-manual
射頻電子 - [實驗第一章] 基頻放大器設計
射頻電子 - [實驗第一章] 基頻放大器設計
mBot 教學10 藍牙控制應用
mBot 教學10 藍牙控制應用
射頻電子實驗手冊 - [實驗7] 射頻放大器模擬
射頻電子實驗手冊 - [實驗7] 射頻放大器模擬
Microbit 1 introduction
Microbit 1 introduction
mBot 教學2 mBlock積木式設計程式
mBot 教學2 mBlock積木式設計程式
Agilent ADS 模擬手冊 [實習1] 基本操作與射頻放大器設計
Agilent ADS 模擬手冊 [實習1] 基本操作與射頻放大器設計
教學(10)藍牙控制應用
教學(10)藍牙控制應用
Python與Ardinio整合應用
Python與Ardinio整合應用
射頻電子實驗手冊 - [實驗8] 低雜訊放大器模擬
射頻電子實驗手冊 - [實驗8] 低雜訊放大器模擬
移植FreeRTOS 之嵌入式軟體研究與開發
移植FreeRTOS 之嵌入式軟體研究與開發
期末專題報告書
期末專題報告書
mBot教學(4) - 移動控制
mBot教學(4) - 移動控制
射頻電子 - [實驗第二章] I/O電路設計
射頻電子 - [實驗第二章] I/O電路設計
Similar to Arduino 習作工坊 - Lesson 4 通訊之夜
認識 RoBoard 硬體
認識 RoBoard 硬體
roboard
Arduino Basic
Arduino Basic
mmiwwcom
Arduino基礎IO控制
Arduino基礎IO控制
吳錫修 (ShyiShiou Wu)
Arduino overview
Arduino overview
吳錫修 (ShyiShiou Wu)
Arduino overview
Arduino overview
吳錫修 (ShyiShiou Wu)
20170415- 智慧空調通訊系統實務_柯大
20170415- 智慧空調通訊系統實務_柯大
MAKERPRO.cc
節錄_ARM Cortex-M 韌體開發設計
節錄_ARM Cortex-M 韌體開發設計
ssuserb0f090
艾鍗學院-單晶片韌體-CC2500通訊實驗
艾鍗學院-單晶片韌體-CC2500通訊實驗
艾鍗科技
IoT 與 WoT 物聯網裝置實作:使用 Arch Pro 與 mbed
IoT 與 WoT 物聯網裝置實作:使用 Arch Pro 與 mbed
Bang Min Shiue
FD620K1
FD620K1
huayuliang
Arduino導讀
Arduino導讀
GUO CHENG-YAN
使用 Arduino 控制 ESP8266 的各種方式
使用 Arduino 控制 ESP8266 的各種方式
Kenson Chiang
Stm32 technical slide_pdf
Stm32 technical slide_pdf
Anshab Bharakath Ali
LinkIt Smart 7688程式開發
LinkIt Smart 7688程式開發
Wei-Tsung Su
AMA 中級術科實作II
AMA 中級術科實作II
吳錫修 (ShyiShiou Wu)
Arduino L2
Arduino L2
mmiwwcom
物聯網技術分享 使用ESP8266
物聯網技術分享 使用ESP8266
Power Wu
12022.10.14.pdf
12022.10.14.pdf
ssuser2523cd
nodeMCU IOT教學03 - NodeMCU導論
nodeMCU IOT教學03 - NodeMCU導論
吳錫修 (ShyiShiou Wu)
nodeMCU IOT教學03 - NodeMCU導論
nodeMCU IOT教學03 - NodeMCU導論
吳錫修 (ShyiShiou Wu)
Similar to Arduino 習作工坊 - Lesson 4 通訊之夜
(20)
認識 RoBoard 硬體
認識 RoBoard 硬體
Arduino Basic
Arduino Basic
Arduino基礎IO控制
Arduino基礎IO控制
Arduino overview
Arduino overview
Arduino overview
Arduino overview
20170415- 智慧空調通訊系統實務_柯大
20170415- 智慧空調通訊系統實務_柯大
節錄_ARM Cortex-M 韌體開發設計
節錄_ARM Cortex-M 韌體開發設計
艾鍗學院-單晶片韌體-CC2500通訊實驗
艾鍗學院-單晶片韌體-CC2500通訊實驗
IoT 與 WoT 物聯網裝置實作:使用 Arch Pro 與 mbed
IoT 與 WoT 物聯網裝置實作:使用 Arch Pro 與 mbed
FD620K1
FD620K1
Arduino導讀
Arduino導讀
使用 Arduino 控制 ESP8266 的各種方式
使用 Arduino 控制 ESP8266 的各種方式
Stm32 technical slide_pdf
Stm32 technical slide_pdf
LinkIt Smart 7688程式開發
LinkIt Smart 7688程式開發
AMA 中級術科實作II
AMA 中級術科實作II
Arduino L2
Arduino L2
物聯網技術分享 使用ESP8266
物聯網技術分享 使用ESP8266
12022.10.14.pdf
12022.10.14.pdf
nodeMCU IOT教學03 - NodeMCU導論
nodeMCU IOT教學03 - NodeMCU導論
nodeMCU IOT教學03 - NodeMCU導論
nodeMCU IOT教學03 - NodeMCU導論
More from CAVEDU Education
Google TPU Edge SBC_190424
Google TPU Edge SBC_190424
CAVEDU Education
From computational Thinking to computational Action - Dr. Hal Abelson, MIT Ap...
From computational Thinking to computational Action - Dr. Hal Abelson, MIT Ap...
CAVEDU Education
180321 MIT見聞分享
180321 MIT見聞分享
CAVEDU Education
BBC Micro:bit beginner project
BBC Micro:bit beginner project
CAVEDU Education
LINE Messaging API with LinkIt 7697
LINE Messaging API with LinkIt 7697
CAVEDU Education
Latte panda workshop_japan
Latte panda workshop_japan
CAVEDU Education
拿鐵熊貓外殼設計0707
拿鐵熊貓外殼設計0707
CAVEDU Education
LinkIt 7697 outer case - DesignSpark Mechanical / Onkscape
LinkIt 7697 outer case - DesignSpark Mechanical / Onkscape
CAVEDU Education
170615 國中小自造者教育師資培訓營
170615 國中小自造者教育師資培訓營
CAVEDU Education
170522_Raspberry Pi 相容開發板
170522_Raspberry Pi 相容開發板
CAVEDU Education
LinkIt 7697 IoT tutorial
LinkIt 7697 IoT tutorial
CAVEDU Education
Maker Movement and Education in Taiwan
Maker Movement and Education in Taiwan
CAVEDU Education
物聯網教學與上海深圳maker行
物聯網教學與上海深圳maker行
CAVEDU Education
161123
161123
CAVEDU Education
IBM以雲端技術與物聯網創新產業應用@2016 New Taipei Maker Faire
IBM以雲端技術與物聯網創新產業應用@2016 New Taipei Maker Faire
CAVEDU Education
AAEON 當創客碰上UP板 - Intel Cherry Trail 高效能maker開發者平台@2016 new taipei maker faire
AAEON 當創客碰上UP板 - Intel Cherry Trail 高效能maker開發者平台@2016 new taipei maker faire
CAVEDU Education
物聯網好棒棒 您專屬的IoT私有雲平台
物聯網好棒棒 您專屬的IoT私有雲平台
CAVEDU Education
絕地武士心靈控制家用雲端智慧型物聯網光劍搭載無線路由器光劍底座Final
絕地武士心靈控制家用雲端智慧型物聯網光劍搭載無線路由器光劍底座Final
CAVEDU Education
LinkIt ONE tutorial #1- Basics
LinkIt ONE tutorial #1- Basics
CAVEDU Education
LinkIt ONE tutorial #2- Communication and cloud service
LinkIt ONE tutorial #2- Communication and cloud service
CAVEDU Education
More from CAVEDU Education
(20)
Google TPU Edge SBC_190424
Google TPU Edge SBC_190424
From computational Thinking to computational Action - Dr. Hal Abelson, MIT Ap...
From computational Thinking to computational Action - Dr. Hal Abelson, MIT Ap...
180321 MIT見聞分享
180321 MIT見聞分享
BBC Micro:bit beginner project
BBC Micro:bit beginner project
LINE Messaging API with LinkIt 7697
LINE Messaging API with LinkIt 7697
Latte panda workshop_japan
Latte panda workshop_japan
拿鐵熊貓外殼設計0707
拿鐵熊貓外殼設計0707
LinkIt 7697 outer case - DesignSpark Mechanical / Onkscape
LinkIt 7697 outer case - DesignSpark Mechanical / Onkscape
170615 國中小自造者教育師資培訓營
170615 國中小自造者教育師資培訓營
170522_Raspberry Pi 相容開發板
170522_Raspberry Pi 相容開發板
LinkIt 7697 IoT tutorial
LinkIt 7697 IoT tutorial
Maker Movement and Education in Taiwan
Maker Movement and Education in Taiwan
物聯網教學與上海深圳maker行
物聯網教學與上海深圳maker行
161123
161123
IBM以雲端技術與物聯網創新產業應用@2016 New Taipei Maker Faire
IBM以雲端技術與物聯網創新產業應用@2016 New Taipei Maker Faire
AAEON 當創客碰上UP板 - Intel Cherry Trail 高效能maker開發者平台@2016 new taipei maker faire
AAEON 當創客碰上UP板 - Intel Cherry Trail 高效能maker開發者平台@2016 new taipei maker faire
物聯網好棒棒 您專屬的IoT私有雲平台
物聯網好棒棒 您專屬的IoT私有雲平台
絕地武士心靈控制家用雲端智慧型物聯網光劍搭載無線路由器光劍底座Final
絕地武士心靈控制家用雲端智慧型物聯網光劍搭載無線路由器光劍底座Final
LinkIt ONE tutorial #1- Basics
LinkIt ONE tutorial #1- Basics
LinkIt ONE tutorial #2- Communication and cloud service
LinkIt ONE tutorial #2- Communication and cloud service
Arduino 習作工坊 - Lesson 4 通訊之夜
1.
Arduino Plus MakerBar Taipei
Workshop
2.
3.
4.
Part 1:藍牙
5.
JY-MCU • • • • • • 預設 Baud rate 9600 Name
HC-0X Pairing code 1234
6.
Pin ID Description 1
EN Enable / Disable module 2 VCC 3.6V ~ 6V 3 GND Comman Ground 4 TXD UART TXD Output 5 RXD UART RXD Input 6 STATE
7.
USB to TTL
8.
AT Command • 修改Baud
rate, name, password…. 網址→Arduino as an USB to TTL adapter 網址→AT指令集
9.
藍牙接Arduino Arduino 藍牙模組 備註 5V
VCC 注意電源不可接錯 GND GND 注意電源不可接錯 RXD (pin 0) RXD TXD (pin 1) TXD
10.
測試藍牙連接 打開 Serial Monitor 把換行模式改成
"No line ending" 接著輸入 AT 指令(指令全部大寫) 然後按下 Send 按鈕或 Enter 鍵 這時藍牙模組應該會回應 OK 註:此時需接一條線在Arduino的GND與RESET,讓 Arduino停留在TTL mode
11.
修改藍牙名稱 • 修改藍牙設備名稱(預設為 linvor) 指令:AT+NAME<p> 回應:OKsetname 其中: <p>
為 Parameter,即設備名稱,有效字元 20 個 範例:將藍牙設備名稱改為 CAVEDU 指令:AT+NAMECAVEDU 回應:OKsetname • 修改藍牙配對密碼(預設為 1234) 指令:AT+PIN<p> 回應:OKsetPIN 其中: <p> 為 Parameter,即配對密碼,有效字元 4 個 範例:將配對密碼改為 5678 指令:AT+PIN5678 回應:OKsetPIN
12.
註:記得將接在Arduino的GND與RESET中間的線拔掉,解除TTL Mode Part 1:藍牙 EX1:LED
13.
App Inventor2
14.
App Inventor2
15.
App Inventor2 http://ai2.appinventor.mit.edu/
16.
Installing and Running
the Emulator in AI2 • 下載模擬器 http://appinventor.mit.edu/explore/ai2/setup-emulator.html • 打開 Aistarter
17.
下載MIT AI2 Companion
App
18.
讓手機可安裝App Inventor程式 • 需要在手機的設定 頁面中完成「未知 的來源」、「USB 除錯中」、「允許 模擬位置」等設定 •
連接Wifi
19.
嘗試連接模擬器及手機 • Connect =>
Emulator • Connect => Reset • Connect => AI Companion
20.
釐清副檔名 • .apk • 手機
app • .aia • app inventor 程式原始檔 • .fzz • fritzing原始檔 20
21.
手機程式
22.
手機程式
23.
手機程式
24.
ASCII Code ASCII(American Standard Code for Information Interchange,美國訊息交換 標準代碼)是基於拉丁字母的一套電腦編碼系統。它主要用於顯示現代英語,而 其擴展版本EASCII則可以部分支援其他西歐語言,並等同於國際標準ISO/IEC
646。 由於全球資訊網使得ASCII廣為通用,直到2007年12月,逐漸被Unicode取代。 常用到的ASCII Code 圖形 十進制 圖形 十進制 圖形 十進制 0 48 5 53 a 97 1 49 6 54 b 98 2 50 7 55 c 99 3 51 8 56 A 65 4 52 9 57 B 66
25.
電路圖 腳位對應表 LED+ 13 LED- GND BT-RXD
11 BT-TXD 10
26.
SoftwareSerial I2CBT(a,b) a=arduino的接收腳(RxD) b=arduino的傳送腳(TxD) 藍牙端TXD接arduino RxD(pin
10) 藍牙端RXD接arduino TxD(pin 11) #include <SoftwareSerial.h> #include <Wire.h> int LED = 13; SoftwareSerial I2CBT(10,11); void setup() { Serial.begin(9600); I2CBT.begin(9600); pinMode(LED, OUTPUT); } void loop() { byte cmmd[20]; int insize; while(1){ /* read message from bluetooth */ if ((insize=(I2CBT.available()))>0){ Serial.print("input size = "); Serial.println(insize); for (int i=0; i<insize; i++){ Serial.print(cmmd[i]=char(I2CBT.read())); Serial.print("n"); } }
27.
switch (cmmd[0]) { case
97: //"a" digitalWrite(LED,HIGH); break; case 98://"b" digitalWrite(LED,LOW); break; } //Switch } //while }
28.
Part 1:藍牙 EX2:Slider
29.
手機程式
30.
手機程式
31.
手機程式
32.
手機程式
33.
#include <SoftwareSerial.h> #include <Wire.h> SoftwareSerial
I2CBT(10,11); void setup() { Serial.begin(9600); I2CBT.begin(9600); pinMode(9,OUTPUT); } ///////////////////main//////////////// void loop() { byte cmmd[20]; int insize; int a=0; while(1){ if ((insize=(I2CBT.available()))>0){ Serial.print("input size = "); Serial.println(insize); for (int i=0; i<insize; i++){ //cmmd[i]=char(I2CBT.read()); Serial.print(cmmd[i]=char(I2CBT.read())); Serial.print(" "); } Serial.println(" "); }
34.
if(insize==4){ a = (cmmd[0]-48)*10; a=a+(cmmd[1]-48); } if(insize==3){ a=(cmmd[0]-48); } Serial.println(a); analogWrite(9,map(a,0,80,0,255)); }
//while }
35.
Part 1:藍牙 EX3:Send message
to phone
36.
到目前為止,我們使用的傳輸方式仍然符合無線傳 輸的限定範圍,也就是說資料都在0~255之間。 但如果今天有一筆資料是超過這個範圍的要如何進 行傳輸?
37.
封包的傳送與接收 封包(Packet): 電腦傳輸資料的基本單位,通常一 個 標頭加上一段資料,就可稱為一個封包。
38.
封包的傳送與接收 如果我們有一筆1013的資料,要如何做成封包? 編碼 高位元 資料 低位元 資料 建立封包
39.
封包的傳送與接收 收到此陣列資料Data[2] 後,要如何將其解碼並求得 值為多少? 編碼 確認起始封包位 計算高低位元 求得其值
40.
封包的傳送與接收 在電腦端,一個位元組的資料是0~255,但是當資 料傳送到Arduino時,它卻會將128~255的資料誤 判為-128~-1。 1位元組: 0~255 解碼 PC: 0~127→Arduino:
0~127 PC: 128~255→Arduino: -128~-1
41.
封包的傳送與接收
42.
封包解碼與接收
43.
電路圖 元件 arduino VR-訊號線 A0 BT-TXD
10 BT-RXD 11 BT-GND GND VR-GND BT-Vcc 5V VR-5V
44.
手機程式
45.
手機程式
46.
手機程式
47.
#include <SoftwareSerial.h> #include <Wire.h> SoftwareSerial
I2CBT(10,11); byte serialA; void setup(){ //define pin modes for tx,rx pin pinMode(10,INPUT); pinMode(11,OUTPUT); Serial.begin(9600); I2CBT.begin(9600); } ///////////////////main/////////////////// void loop (){ byte Data[3]; byte cmmd[20]; int insize; int i=analogRead(A0); serialA=I2CBT.read(); Data[0]='a'; Data[1]=i/256; Data[2]=i%256; Serial.println(i); if (serialA == 49){ for(int j=0;j<3;j++) I2CBT.write(Data[j]); serialA=0; } delay(100); } 封包
48.
48 app inventor 經由clock 用藍芽傳送a arduino收到a之後 用藍芽傳送data app inventor收到Data[0]=a 接收其他data[1]
data[2] 再解封包 程式邏輯
49.
CAVEDU:雙A計劃 • Appinventor+Arduino – Part
0 – Part 1 – Part 2 – Part 3
50.
Part 2:紅外線
51.
51 http://www.mobile01.com/topicdetail.php?f=168&t=4135366&p=1#52856899
52.
紅外線 紅外線是目前最常見的一種無線通訊,普遍使 用在家電以及玩具產品,如電視、音響、錄放 影機、冷氣機、DVD、MP3 Player、遙控車 等。紅外線遙控之所以被大量採使用,主要是 因為紅外線裝置體積小、成本低、耗電少及硬 體設計容易。
53.
54.
Add library • <IRremote.h> –
IRrecv irrecv(irReceiverPin); // 定義 IRrecv 物件來接收紅外線訊號 – irrecv.enableIRIn(); // 啟動紅外線解碼 – showIRProtocol // 顯示紅外線協定種類
55.
Part 2:紅外線 EX1:TurnOnLED
56.
TURNON_LED/* * IRRemote 紅外線遙控教學 *
範例 1.2: 顯示紅外線協定種類; 如 NEC, Sony SIRC, Philips RC5, Philips RC6 等協定 */ #include <IRremote.h> // 引用 IRRemote 函式庫 const int irReceiverPin = 2; // 紅外線接收器 OUTPUT 訊號接在 pin 2 int i=0; IRrecv irrecv(irReceiverPin); // 定義 IRrecv 物件來接收紅外線訊號 decode_results results; // 解碼結果將放在 decode_results 結構的 result 變數裏 int LED=13; void setup() { Serial.begin(9600); // 開啟 Serial port, 通訊速率為 9600 bps irrecv.enableIRIn(); // 啟動紅外線解碼 pinMode(13,OUTPUT); } 5v GND arduino-2
57.
// 顯示紅外線協定種類 void showIRProtocol(decode_results
*results) { Serial.print("Protocol: "); // 判斷紅外線協定種類 switch(results->decode_type) { case NEC: Serial.print("NEC"); break; case SONY: Serial.print("SONY"); break; case RC5: Serial.print("RC5"); break; case RC6: Serial.print("RC6"); break; default: Serial.print("Unknown encoding"); } // 把紅外線編碼印到 Serial port Serial.print(", irCode: "); Serial.print(results->value, HEX); // 紅外線編碼 Serial.print(", bits: "); Serial.println(results->bits); // 紅外線編碼位元數 } void loop() { if (irrecv.decode(&results)) { if (results.value != -1) { showIRProtocol(&results); if(i==0) { digitalWrite(LED, HIGH); i=i+1; } else if(i==1) { digitalWrite(LED, LOW); i=i-1; } } irrecv.resume(); // 搬到外面來 } }
58.
Part 2:紅外線 EX2:Fade the
LED
59.
FADE_LED /* * IRRemote 紅外線遙控教學 *
範例 1.2: 顯示紅外線協定種類; 如 NEC, Sony SIRC, Philips RC5, Philips RC6 等協定 */ #include <IRremote.h> // 引用 IRRemote 函式庫 const int irReceiverPin = 2; // 紅外線接收器 OUTPUT 訊號接在 pin 2 int i=0; IRrecv irrecv(irReceiverPin); // 定義 IRrecv 物件來接收紅外線訊號 decode_results results; // 解碼結果將放在 decode_results 結構的 result 變數裏 void setup() { Serial.begin(9600); // 開啟 Serial port, 通訊速率為 9600 bps irrecv.enableIRIn(); // 啟動紅外線解碼 pinMode(13,OUTPUT); }
60.
// 顯示紅外線協定種類 void showIRProtocol(decode_results
*results) { Serial.print("Protocol: "); // 判斷紅外線協定種類 switch(results->decode_type) { case NEC: Serial.print("NEC"); break; case SONY: Serial.print("SONY"); break; case RC5: Serial.print("RC5"); break; case RC6: Serial.print("RC6"); break; default: Serial.print("Unknown encoding"); } // 把紅外線編碼印到 Serial port Serial.print(", irCode: "); Serial.print(results->value, HEX); // 紅外線編碼 Serial.print(", bits: "); Serial.println(results->bits); // 紅外線編碼位元數 } void loop() { if (irrecv.decode(&results)) { // 解碼成功,收到一組紅外線 訊號 showIRProtocol(&results); // 顯示紅外線協定種類 irrecv.resume(); // 繼續收下一組紅外線訊號 void loop() { if (irrecv.decode(&results)) { if (results.value != -1) { showIRProtocol(&results); if(i==0) { analogWrite(9, 0); i=i+1; } else if(i==1) { analogWrite(9, 64); i=i+1; } else if(i==2) { analogWrite(9, 255); i=i-2; } Serial.println(i); } irrecv.resume(); // } }
61.
參考資料 • CooperMaa 紅外線遙控教學
62.
CAVEDU 教育團隊 按個讚吧
Editor's Notes
EDR改進型資料傳輸率
Download now