(感謝鋼鐵人實作聯盟阿立的帶領.)
萊恩大兵參加 BLE 研究會, 最開始的期待, 大抵就是能對 CC2540 和 BLE 4.0 技術有些認識就夠了. 可是..
萊恩大兵摸索 BLE 和 iOS 程式開發的歷程, 可參考這幾篇文章的分享.
* 筆記, CC2540 Bluetooth Low Energy, (1) 開發環境 架設 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (2) 跑第一個範例程式 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (3) SimpleBLEPeripheral 簡單介紹 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (4) 在智慧手機上執行範例程式 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (5) 偵測與發送 iBeacon 訊號 (Bluetooth, CC2540, iBeacon)
* 實作, iBeacon 發訊器 x 防丟器 (Bluetooth, CC2540, iBeacon)
* 實作, iBeacon 尋寶遊戲 (Bluetooth, CC2540, iBeacon, iOS app)
* 筆記, CC2540 Bluetooth Low Energy, (2) 跑第一個範例程式 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (3) SimpleBLEPeripheral 簡單介紹 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (4) 在智慧手機上執行範例程式 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (5) 偵測與發送 iBeacon 訊號 (Bluetooth, CC2540, iBeacon)
* 實作, iBeacon 發訊器 x 防丟器 (Bluetooth, CC2540, iBeacon)
* 實作, iBeacon 尋寶遊戲 (Bluetooth, CC2540, iBeacon, iOS app)
從阿立那邊拿到一組 LED 燈板, 剛好無錫谷雨那邊也有個藍牙枱燈 (SimpleBLEPeripheral_DeskLamp) 的示範. 就用它們來做個遙控電燈開關好了.
需要的硬體裝置有:
* CC2540 開發板
![]() |
得燒錄 SimpleBLEPeripheral_DeskLamp 的軔體 |
* LED 燈板
說明一下:
CC2540 得燒錄上無錫谷雨藍牙枱燈專案 (SimpleBLEPeripheral_DeskLamp) 的軔體, 這隻程式 (藍牙枱燈) 會對 P0.7 GPIO 針腳送出 0 或 1 的訊號.
CC2540 和 LED 燈板的連接方式如下:
3.3V (CC2540 ) <-> 電源針腳 (LED 燈板)
P0.7 (CC2540) <-> LED 針腳 (LED 燈板)
iOS app 的名字叫做 遙控燈泡君.
![]() |
AppIcon |
Launch Image |
這隻 app 開啟後, 會自動搜尋附近四周的藍牙裝置, 並和它建立連線. 再透過 (Service = "FFF0", Characteristic="FFF1") 介面去控制 LED 的亮滅. 很簡單的一個功能.
萊恩大兵擔心它的畫面太樸素不好看, 花了一些工夫, 把它包裝得好看一點. 看圖就大概可以了解它的操作流程.
關於這隻 app, 有兩個特點要說.
(1) 它和藍牙裝置連線後, 或是送出開燈/關燈指令後, 會先去查詢 characteristic 值狀態 (亮/滅), 再依 characteristic 值來顯示正確的圖檔 (燈泡亮/燈泡滅). 並不是盲目的變更 app 端的圖檔, 這有比一般的紅外線遙控器厲害一點.
(2) 它的程式碼就是 iOS 的 Core Bluetooth framework 裡, 很基本的 BLE Central Manager 連線實作. 這邊萊恩大兵就列幾個 keyword 供有興趣的朋友 google-ing.
- centralManagerDidUpdateState
- didDiscoverPeripheral
- didFailToConnectPeripheral
- cancelPeripheralConnection
- didConnectPeripheral
- didDiscoverServices
- didDiscoverCharacteristicsForService
- didUpdateValueForCharacteristic
- didUpdateNotificationStateForCharacteristic
- didDisconnectPeripheral
詳細程式開發細節, 可參考這幾篇文章.
* iOS 7 SDK: Core Bluetooth - Practical Lesson
* Performing Common Central Role Tasks
這隻程式的程式碼已放上 Github (https://github.com/GoGoPrivateRyan/CBRemoteController), 請自行取用.
最後說一點想法.. 萊恩大兵個人觀點, 這整個 (iOS app, CC2540 開發板, LED 燈板) 的整合, 看起來很炫. 其實只是很直觀的無線搖控應用而已. 還沒摸到雲端或物聯網. 以後有機會, 萊恩大兵會再嚐試加入雲端或物聯網的成份進來.
[萊恩大兵的其它文章]
自製大四軸
* 自製大四軸, 實作分享@華山文創園區
* 自製大四軸, (1) 零組件篇, 遙控器 (Drone, Quadcopter, Futaba, Maker, Arduino, Animatronic Eye)
* 自製大四軸, (2) 零組件篇, 飛控板 (Drone, Quadcopter, MultiWii, Arduino, Futaba, Maker)
* 自製大四軸, (3) 零組件篇, 自行雷切木質機架 (Drone, Quadcopter, Maker, Laser Cut)
* 自製大四軸, (4) 零組件篇, 馬達與電變調整 (Drone, Quadcopter, Maker, Electric Speed Control, Motor)
* 自製大四軸, (5) 組裝篇, 四軸飛行器成形 (Drone, Quadcopter, MultiWii, Arduino, Maker, Electric Speed Control, Motor)
* 自製大四軸, (6) 調整篇, 飛行前兩三事 (Drone, Quadcopter, Maker, Futaba, Arduino, MultiWii)
* 自製大四軸, (7) 充電篇, iMax B6 充電器操作記要 (Charger, Battery)
* 自製大四軸, (8) 問題篇, 機架損壞維修 (Drone, Quadcopter, Laser Cut)
* 自製大四軸, (9) 改良篇, 方便拆卸的木質機架 (Drone, Quadcopter, Maker, Laser Cut)
* 自製大四軸, (10) 外飛篇, 新手的青蛙跳與遛狗 (Drone, Quadcopter, Maker, MultiWii)
自動報球速的棒球
* 自動報球速的棒球, (1) 概念與雛形 (Arduino, MPU-6050, HC-06)
* 自動報球速的棒球, (2) 第一版試作品 (Arduino, NanoWii, microSD, MPU6050)
* 自動報球速的棒球, (3) 拋接實驗的數據分析 (Arduino, NanoWii, microSD, MPU6050)
* 自動報球速的棒球, (2) 第一版試作品 (Arduino, NanoWii, microSD, MPU6050)
* 自動報球速的棒球, (3) 拋接實驗的數據分析 (Arduino, NanoWii, microSD, MPU6050)
* 做實驗, 寫入 EEPROM 的速度能否跟得上 MPU6050 的數據產出? (Arduino, MPU-6050, EEPROM)
* 筆記, NanoWii, 一些經驗分享 (Arduino, NanoWii, MPU6050)
* Murmur, 很小很強大的穿戴式裝置模組 (Realtag, Bluetooth, CC2540, MPU6050, BMP180)
* 筆記, NanoWii, 一些經驗分享 (Arduino, NanoWii, MPU6050)
* Murmur, 很小很強大的穿戴式裝置模組 (Realtag, Bluetooth, CC2540, MPU6050, BMP180)
CC2540 Bluetooth Low Energy
* 筆記, CC2540 Bluetooth Low Energy, (1) 開發環境 架設 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (2) 跑第一個範例程式 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (3) SimpleBLEPeripheral 簡單介紹 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (4) 在智慧手機上執行範例程式 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (5) 偵測與發送 iBeacon 訊號 (Bluetooth, CC2540, iBeacon)
* 實作, iBeacon 發訊器 x 防丟器 (Bluetooth, CC2540, iBeacon)
* 實作, iBeacon 尋寶遊戲 (Bluetooth, CC2540, iBeacon, iOS app)
* 實作, BLE + iOS app, 遙控燈泡君 (Bluetooth, CC2540, iOS app)
* 做實驗, 用 iBeacon 做自動控制的可行性 (Bluetooth, iBeacon, CC2540, Automation, URL Scheme, iOS app)
* 筆記, CC2540 Bluetooth Low Energy, (2) 跑第一個範例程式 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (3) SimpleBLEPeripheral 簡單介紹 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (4) 在智慧手機上執行範例程式 (Bluetooth, CC2540)
* 筆記, CC2540 Bluetooth Low Energy, (5) 偵測與發送 iBeacon 訊號 (Bluetooth, CC2540, iBeacon)
* 實作, iBeacon 發訊器 x 防丟器 (Bluetooth, CC2540, iBeacon)
* 實作, iBeacon 尋寶遊戲 (Bluetooth, CC2540, iBeacon, iOS app)
* 實作, BLE + iOS app, 遙控燈泡君 (Bluetooth, CC2540, iOS app)
* 做實驗, 用 iBeacon 做自動控制的可行性 (Bluetooth, iBeacon, CC2540, Automation, URL Scheme, iOS app)
藍色小鋪一起來做
* 藍色小鋪一起來做, (1) 用 beacon 控制開關的枱燈
* 藍色小鋪一起來做, (2) 講解 BLE CC2540 UART 通訊範例程式 (Bluetooth, CC2540, UART)
* 藍色小鋪一起來做, (3) 藍牙枱燈專案實作 (上) (Bluetooth, CC2540)
* 藍色小鋪一起來做, (4) 藍牙枱燈專案實作 (下) (Bluetooth, CC2540)
* 藍色小鋪一起來做, (5) iBeacon scanner 專案示範與解說 (Bluetooth, CC2540, iBeacon)
* 藍色小鋪一起來做, (6) 完成, 用 iBeacon 控制開關的枱燈 (Bluetooth, CC2540, iBeacon)
* 藍色小鋪, 初嚐樹莓派 (Raspberry Pi)
* 藍色小鋪, iBeacon 應用, 自動記錄到訪時間 (iBeacon, Geohopper, Zapier)
* 藍色小鋪, 菲力普的 Docker 應用分享 (Docker)
* 藍色小鋪, PTT地震文團隊分享三連發, (1) Maker 的 IOT 遊樂場 (PTT, Hackathon, Python, Xively, Internet of Things)
* 藍色小鋪, PTT地震文團隊分享三連發, (2) mbed 新手分享 (mbed, MPU6050, Hackathon, Internet of Things)
* 藍色小鋪, 空中提升軌道車, 作品進化分享 (Pneumatic Tube System, Force of Friction, Mini 4 WD)
* 藍色小鋪, 數字管時鐘, 作品進化分享 (Nixie Tube, VFD)
OpenCV 學習路徑
* 記錄, OpenCV 學習路徑, (1) 環境安裝與第一個範例 (OpenCV, Python)
小惡魔 無線溫度感測器
* 小惡魔, (1) 溫度感測 + 物聯網 (Electric Imp, Xively, LM35, Internet of Things)
* 小惡魔, (2) 溫度感測 + 物聯網 + 事件觸發 (Electric Imp, Xively, LM35, Internet of Things)
* 小惡魔, (2) 溫度感測 + 物聯網 + 事件觸發 (Electric Imp, Xively, LM35, Internet of Things)
108 大眼仔
Plot Clock
* 體驗, 蛋生音互動裝置@兒童美術館 (Arduino, 3D Printing, HC-SR04, Interactive)
* 實作, 電容感應音樂樹
* 修理, 樂高馬達 8883 (LEGO 8883 Power Functions M-Motor)
* 修理, (part 2) 樂高馬達 8883 (LEGO 8883 Power Functions M-Motor)
* 修理, 液晶螢幕 (LCD)
* 108 大眼仔, 初登場 (Arduino, SG-90, Maker Faire Taipei 2014, Animatronic Eye)
* 108 大眼仔, 進化, (1) 專屬程式庫 (Arduino, SG90, Animatronic Eye)
* 108 大眼仔, 進化, (2) 當我們串在一起 (Arduino, SG90, Animatronic Eye, I2C)
* 108 大眼仔, 進化, (3) 檢查 Gmail 信箱 (Arduino, SG90, Animatronic Eye, Temboo)
* 108 大眼仔, 進化, (4) 看著我的臉 (Arduino, SG90, Animatronic Eye, OpenCV, Processing, I2C)
* 108 大眼仔, 進化, (5) 迎著人來人往 (Arduino, SG90, Animatronic Eye, OpenCV, Processing, I2C)
* 108 大眼仔, 檢討筆記, 我要一個打十個 (Arduino, SG90, Animatronic Eye)
* 108 大眼仔, 進化, (1) 專屬程式庫 (Arduino, SG90, Animatronic Eye)
* 108 大眼仔, 進化, (2) 當我們串在一起 (Arduino, SG90, Animatronic Eye, I2C)
* 108 大眼仔, 進化, (3) 檢查 Gmail 信箱 (Arduino, SG90, Animatronic Eye, Temboo)
* 108 大眼仔, 進化, (4) 看著我的臉 (Arduino, SG90, Animatronic Eye, OpenCV, Processing, I2C)
* 108 大眼仔, 進化, (5) 迎著人來人往 (Arduino, SG90, Animatronic Eye, OpenCV, Processing, I2C)
* 108 大眼仔, 檢討筆記, 我要一個打十個 (Arduino, SG90, Animatronic Eye)
* 自造 Time Plotting Clock, (1) 零件採購
* 自造 Time Plotting Clock, (2) 組裝
* 自造 Time Plotting Clock, (3) 校正
* 自造 Time Plotting Clock, (2) 組裝
* 自造 Time Plotting Clock, (3) 校正
* Murmur, 有趣的零件售價
* Murmur, Arduino 保險桿 (Arduino, bumper, 3D printing)
* Murmur, 許一個 maker 分享網站
* Murmur, 物聯網新概念- The Physical Web (Internet of Things, The Physical Web)
* Murmur, 關於 HP Sprout 的一點想法
* Murmur, 說中文很難嗎? (Toy, Reed Switch, Voice Recorder Module)
* Murmur, 停車場自動繳費機的兩三事 (Kiosk)
* Murmur, 為什麼是 WiFi? 關於小米空氣清淨器的一點看法.. (Internet of Things)
* Murmur, 機器人是時尚元素? (Robot, Fashion)
* Murmur, Nordic 才會是 Bluetooth LE 晶片戰爭的恐龍王者? (Bluetooth, Nordic)
* Murmur, Maker Faire Taipei 2015, 讓人印象深刻的創作品 (Maker Faire Taipei)
* 體驗, 原住民互動故事書@宜蘭大同鄉泰雅生活館* Murmur, Arduino 保險桿 (Arduino, bumper, 3D printing)
* Murmur, 許一個 maker 分享網站
* Murmur, 物聯網新概念- The Physical Web (Internet of Things, The Physical Web)
* Murmur, 關於 HP Sprout 的一點想法
* Murmur, 說中文很難嗎? (Toy, Reed Switch, Voice Recorder Module)
* Murmur, 停車場自動繳費機的兩三事 (Kiosk)
* Murmur, 為什麼是 WiFi? 關於小米空氣清淨器的一點看法.. (Internet of Things)
* Murmur, 機器人是時尚元素? (Robot, Fashion)
* Murmur, Nordic 才會是 Bluetooth LE 晶片戰爭的恐龍王者? (Bluetooth, Nordic)
* Murmur, Maker Faire Taipei 2015, 讓人印象深刻的創作品 (Maker Faire Taipei)
* 體驗, 蛋生音互動裝置@兒童美術館 (Arduino, 3D Printing, HC-SR04, Interactive)
* 開箱, 鋼彈小劇場 (Pepper's Ghost, GUNDAM)
* 開箱, Flying Alien Sphere 異形飛球 (Drone, Flying Alien Sphere)
* 開箱, 偉力控二號機, 小四軸飛行器 (CG022, Quadcopter)
* 偉力控二號機, 修理防護罩與飛行心得 (CG022, Quadcopter)
* 偉力控二號機, 我想有個家 (CG022, Quadcopter)
* 偉力控二號機, 換馬達 (CG022, Quadcopter)
* 偉力控二號機, 盒子上的洞 (CG022, Quadcopter)
* 開箱, Flying Alien Sphere 異形飛球 (Drone, Flying Alien Sphere)
* 開箱, 偉力控二號機, 小四軸飛行器 (CG022, Quadcopter)
* 偉力控二號機, 修理防護罩與飛行心得 (CG022, Quadcopter)
* 偉力控二號機, 我想有個家 (CG022, Quadcopter)
* 偉力控二號機, 換馬達 (CG022, Quadcopter)
* 偉力控二號機, 盒子上的洞 (CG022, Quadcopter)
* 筆記, microSD 模組, 一些經驗分享 (Arduino, microSD)
* 筆記, 低電壓警報器的用法 (Low Voltage Buzzer)
* 筆記, 應用 OpenCV 做目標捕獲 (OpenCV, Python)
* 筆記, 低電壓警報器的用法 (Low Voltage Buzzer)
* 筆記, 應用 OpenCV 做目標捕獲 (OpenCV, Python)
* 修理, 樂高馬達 8883 (LEGO 8883 Power Functions M-Motor)
* 修理, (part 2) 樂高馬達 8883 (LEGO 8883 Power Functions M-Motor)
* 修理, 液晶螢幕 (LCD)
* 想修理, 免治馬桶座的薄膜按鍵開關
* 想拆, 聲控錄音變聲熊本熊 (Kumamon, Vibration Motor, VOX)
* 想拆, 小七的無線充電座 (Wireless Charging, 7-11)
* 拆, 電流急急樂
* 拆, 無線光學滑鼠
* 拆, 元宵節紙雕小燈籠燈芯 (7-color blinking LED)
* 拆, 堅若磐石手電筒
* 拆, 省電燈泡 (Compact Fluorescent Bulb)
* 拆, 玩具吸塵器 (toy, step motor, vibration motor)
* 拆, USB 車用充電器 (USB Car Charger)
* 拆, 震動發光充氣加油棒 (LED, vibration switch)
* 想拆, 聲控錄音變聲熊本熊 (Kumamon, Vibration Motor, VOX)
* 想拆, 小七的無線充電座 (Wireless Charging, 7-11)
* 拆, 電流急急樂
* 拆, 無線光學滑鼠
* 拆, 元宵節紙雕小燈籠燈芯 (7-color blinking LED)
* 拆, 堅若磐石手電筒
* 拆, 省電燈泡 (Compact Fluorescent Bulb)
* 拆, 玩具吸塵器 (toy, step motor, vibration motor)
* 拆, USB 車用充電器 (USB Car Charger)
* 拆, 震動發光充氣加油棒 (LED, vibration switch)
bluetooth low energy arduino: http://www.elecfreaks.com/store/products_new.html
回覆刪除要怎麼加入你們的聚會, e-mail : rsyang0327@gmail.com
回覆刪除週二晚上7:30, 在寶藏巖口丁都有固定聚會. 直接來即可.
回覆刪除