Board logo

標題: 新手試試 --- PC BlueTooth USB Dongle to Arduino BlueTooth with LCD Display 試作 [打印本頁]

作者: zonebaby    時間: 2009-9-27 13:10     標題: 新手試試 --- PC BlueTooth USB Dongle to Arduino BlueTooth with LCD Display 試作

上次試過兩個 Arduino 用 BlueTooth 主從方式單向發訊,今次就由PC向 Arduino 發訊,

所以塊 BlueTooth 板仔要用從屬果塊。塊板就用番上次果塊加一個大D既 LCD Display,
同埋加多個 Bluetooth 2 既 USB Dongle 連接PC。

PC BlueTooth USB Dongle to Arduino BlueTooth
PC BlueTooth USB Dongle to Arduino BlueTooth.jpg

圖片附件: PC BlueTooth USB Dongle to Arduino BlueTooth.jpg (2009-9-27 13:10, 58.17 KB) / 下載次數 240
https://h2.hkepc.com/forum/attachment.php?aid=949038&k=001d0d953a06ce9c7723341cc8c2514c&t=1781441225&sid=13lm4A3qwEr


作者: zonebaby    時間: 2009-9-27 13:20

用個舊code改左少少。
  1. // include the library code:
  2. #include <LiquidCrystal.h>

  3. // initialize the library with the numbers of the interface pins
  4. LiquidCrystal lcd(13, 11, 7, 6, 5, 4);

  5. void setup()
  6. {
  7.   pinMode(3,OUTPUT);
  8.   digitalWrite(3,HIGH);
  9.   // set up the LCD's number of rows and columns:
  10.   delay(1000);
  11.   lcd.begin(20, 4);
  12.   // Print a message to the LCD.
  13.   lcd.print("OK");
  14.   // Print a message to the LCD.
  15.   // set the cursor to column 0, line 1
  16.   // (note: line 1 is the second row, since counting begins with 0):
  17.   lcd.setCursor(0, 0);
  18.   Serial.begin(115200);
  19. }

  20. void loop()
  21. {
  22.    char val;
  23.    val = Serial.read();
  24.    if(val!=-1)
  25.     {
  26.         // serial display received char:
  27.                 lcd.print(val);
  28.      }
  29. }
複製代碼

作者: zonebaby    時間: 2009-9-27 13:21

插個 BlueTooth USB Dongle 去PC到就會自己認到同裝個 Driver。
係系統匣就會見到個icon,

BlueTooth icon
BlueTooth icon.gif

係個Device Manager就見到 Bluetooth Radios 同埋 Bluetooth Networks。

Bluetooth Radios
Bluetooth Radios.gif

Bluetooth Networks
Bluetooth Networks.gif

跟住就用Add Bluetooth Device去搵個 Arduino BlueTooth。
冇個icon,就去control panelel搵或者用Run  bthprops.cpl 都可以。

Add Bluetooth Device
Add Bluetooth Device.gif

個 Bluetooth UI 就會彈出來

Bluetooth UI
Bluetooth UI.gif

按 Add 就會準備搜索程序。
但繼續前必須完成拔走個 Bluetooth,compile同upload左個code去 Arduino 到
就再插返個 BlueTooth,然後接電源。

Adding Bluetooth Wizard
Adding Bluetooth Wizard.gif

個 LCD Display 見到OK,就可以繼續。搵到就會見到個 Arduino BlueTooth 名。

bluetooth found
bluetooth found.gif

選左個device就可以繼續,同埋輸入個 Passkey, E塊 Arduino BlueTooth 板用"1234"

Bluetooth Passkey
bluetooth passkey.gif

如果個Passkey正確就會繼續係部PC到加兩個聯絡端口。今次係com port 14,15。

Bluetooth com port
Bluetooth com port.gif

完成後,個Bluetooth UI就會係Devices度多左個device,同埋係個COM ports度多左兩個port。
其中com port 14係用作由PC輪出端口,com port 15係用作由PC接收端口。

bluetooth added device,bluetooth added COM port
bluetooth added device.gif bluetooth added com port.gif

咁就完成左安裝不過就未用得住, 同時Arduino bluetooth 上既Led會閃動。
要用個 Arduino bluetooth 就要先open個port去確認連線, 同時 Arduino bluetooth 上既Led會長著。

圖片附件: BlueTooth icon.gif (2009-9-27 13:21, 1.45 KB) / 下載次數 228
https://h2.hkepc.com/forum/attachment.php?aid=949045&k=a98932ec355458cfa49a85cd40f29815&t=1781441225&sid=13lm4A3qwEr



圖片附件: Bluetooth Radios.gif (2009-9-27 13:21, 12.41 KB) / 下載次數 251
https://h2.hkepc.com/forum/attachment.php?aid=949046&k=b5fb02ef13eb6269439f1f47e34ae20c&t=1781441225&sid=13lm4A3qwEr



圖片附件: Bluetooth Networks.gif (2009-9-27 13:21, 13.89 KB) / 下載次數 243
https://h2.hkepc.com/forum/attachment.php?aid=949047&k=b48355fdb937af4491afb3db30d79ed9&t=1781441225&sid=13lm4A3qwEr



圖片附件: Add Bluetooth Device.gif (2009-9-27 13:21, 3.39 KB) / 下載次數 222
https://h2.hkepc.com/forum/attachment.php?aid=949048&k=e878f2d753c24c03e421ca620071ca19&t=1781441225&sid=13lm4A3qwEr



圖片附件: Bluetooth UI.gif (2009-9-27 13:21, 12.18 KB) / 下載次數 233
https://h2.hkepc.com/forum/attachment.php?aid=949049&k=0c6342ab3fb6f84628995dc0eed39dbb&t=1781441225&sid=13lm4A3qwEr



圖片附件: Adding Bluetooth Wizard.gif (2009-9-27 13:21, 14.54 KB) / 下載次數 245
https://h2.hkepc.com/forum/attachment.php?aid=949050&k=49191694501e0591eeaaa61a77728185&t=1781441225&sid=13lm4A3qwEr



圖片附件: bluetooth found.gif (2009-9-27 13:21, 9.42 KB) / 下載次數 230
https://h2.hkepc.com/forum/attachment.php?aid=949051&k=066f42a6f7749238103eb30287bb9031&t=1781441225&sid=13lm4A3qwEr



圖片附件: bluetooth passkey.gif (2009-9-27 13:21, 10.74 KB) / 下載次數 219
https://h2.hkepc.com/forum/attachment.php?aid=949052&k=45c1f374acb9181bd9dda102ad8ca966&t=1781441225&sid=13lm4A3qwEr



圖片附件: Bluetooth com port.gif (2009-9-27 13:21, 13.55 KB) / 下載次數 257
https://h2.hkepc.com/forum/attachment.php?aid=949053&k=e4a5e8c872c7f435d7f1a4e5457d6471&t=1781441225&sid=13lm4A3qwEr



圖片附件: bluetooth added device.gif (2009-9-27 13:21, 13.22 KB) / 下載次數 281
https://h2.hkepc.com/forum/attachment.php?aid=949054&k=da1b9790fdc59524feed00cee034cf79&t=1781441225&sid=13lm4A3qwEr



圖片附件: bluetooth added com port.gif (2009-9-27 13:21, 16.63 KB) / 下載次數 200
https://h2.hkepc.com/forum/attachment.php?aid=949055&k=a9b5ee8d4a23ae319f24e16d77490214&t=1781441225&sid=13lm4A3qwEr


作者: zonebaby    時間: 2009-9-27 13:21

E個Code都係放在examples入面....

PC BlueTooth USB Dongle to Arduino BlueTooth with LCD Display Location

今次係試下傳送一個Text File,所以就用XP個Hyper terminal,可以係accessories/communication下搵到。

所以就要用根據加左用作輸出的com port 14。

PC_com port
PC_com port.gif

可以用同 Arduino bluetooth 唔同既傳輸speed。

PC_com port speed
PC_com port speed.gif

如果聯絡得上 Arduino bluetooth 上既Led就會長著。
見到Led長著就可以開始傳輸。

Hyper terminal sent file
Hyperterminal sent file.gif

用完就以disconnect

Hyperterminal disconnect
Hyperterminal disconnect.gif

有需要用就再call個 Arduino bluetooth

Hyperterminal connect
Hyperterminal connect.gif.gif

個 Arduino 收到個text file,就會將內容輸出到 LCD Display

PC BlueTooth USB Dongle to Arduino BlueTooth Success
PC BlueTooth USB Dongle to Arduino BlueTooth Success.jpg

PC BlueTooth USB Dongle to Arduino BlueTooth 試機成功....

ps 加番D圖

[ 本帖最後由 zonebaby 於 2009-9-27 13:24 編輯 ]

圖片附件: PC_com port.gif (2009-9-27 13:24, 6.93 KB) / 下載次數 216
https://h2.hkepc.com/forum/attachment.php?aid=949056&k=c08ec428a4a88d7afe8aca85cf7bc191&t=1781441225&sid=13lm4A3qwEr



圖片附件: PC_com port speed.gif (2009-9-27 13:24, 24.25 KB) / 下載次數 220
https://h2.hkepc.com/forum/attachment.php?aid=949057&k=ffea33b5766e87e9c9665f41fc878254&t=1781441225&sid=13lm4A3qwEr



圖片附件: Hyperterminal sent file.gif (2009-9-27 13:24, 5.01 KB) / 下載次數 224
https://h2.hkepc.com/forum/attachment.php?aid=949058&k=0102fbed4d3aec7d3446e4b0a6ff8e65&t=1781441225&sid=13lm4A3qwEr



圖片附件: Hyperterminal disconnect.gif (2009-9-27 13:24, 5.26 KB) / 下載次數 251
https://h2.hkepc.com/forum/attachment.php?aid=949059&k=4faafbb0f6a489680a064d81c2ccd5eb&t=1781441225&sid=13lm4A3qwEr



圖片附件: Hyperterminal connect.gif.gif (2009-9-27 13:24, 4.99 KB) / 下載次數 248
https://h2.hkepc.com/forum/attachment.php?aid=949060&k=7775a7ec16454f7746da42e876a73c47&t=1781441225&sid=13lm4A3qwEr



圖片附件: PC BlueTooth USB Dongle to Arduino BlueTooth Success.jpg (2009-9-27 13:24, 68.75 KB) / 下載次數 241
https://h2.hkepc.com/forum/attachment.php?aid=949061&k=079ed711b212a0baf02a4fc06d315150&t=1781441225&sid=13lm4A3qwEr


作者: zonebaby    時間: 2009-9-27 13:22

後記:

又試下用個 LCD Smartie 由 BlueTooth 發資料。

測試時,有信號錯既問題,幾個speed既設定,試左一輪,至可以正常,遲D至搵下真正原因。
最後將個舊既 LCD Smartie code改左個速度去115200就用得。
但個 LCD Smartie 既速度最高只可以上到19200, 再高就再唔可以聯絡到個 Arduino BlueTooth

LCD Smartie Setup
LCD Smartie Setup.gif

LCD Smartie
LCD Smartie.gif

個code係
  1. /*
  2.   LCD Smartie  testing
  3. */

  4. // include the library code:
  5. #include <LiquidCrystal.h>

  6. // initialize the library with the numbers of the interface pins
  7.      LiquidCrystal lcd(13, 11, 7, 6, 5, 4);
  8.      byte getByte;
  9.      byte temmBbyte[8];

  10. void setup() {
  11.      pinMode(3, OUTPUT);
  12.      Serial.begin(115200);
  13. //   set up the LCD's number of rows and columns:
  14.      lcd.begin(20,4);
  15.      lcd.clear();
  16.      digitalWrite(3, HIGH);
  17. }

  18. byte getSerialByte() {
  19.      int inSerialByte=0;
  20.      while (Serial.available()==0){}
  21.      inSerialByte=Serial.read();
  22.      return (byte) (inSerialByte & 0xff);
  23. }

  24. void loop() {
  25.      getByte=getSerialByte();
  26.      if (getByte==254)
  27.      {
  28. //     test next command byte  
  29.        switch (getSerialByte())
  30.        {
  31.          case  66: //LCD backlight on
  32.                  digitalWrite(3, HIGH);
  33.                  break;
  34.          case  70: //LCD backlight off
  35.                  digitalWrite(3,LOW);
  36.                  break;
  37.          case  71: //LCD position [col] [row]
  38.                  temmBbyte[0]=(getSerialByte()-1);
  39.                  temmBbyte[1]=(getSerialByte()-1);
  40.                  lcd.setCursor(temmBbyte[0],temmBbyte[1]);
  41.                  break;
  42.          case  72: //LCD home
  43.                  lcd.home();
  44.                  break;
  45.          case  74: //LCD underline cursor on
  46.                  lcd.cursor();
  47.                  break;
  48.          case  75: //LCD underline cursor off
  49.                  lcd.noCursor();
  50.                  break;
  51.          case  78: //LCD custom character [no of custom char] [8 bytes char pattern])
  52.                  getByte=getSerialByte();
  53.                  for (int i=0; i<=7; i++)
  54.                  {
  55.                    temmBbyte[i]=getSerialByte();
  56.                  }
  57.                  lcd.createChar(getByte, temmBbyte);
  58.                  break;
  59.          case  83: //LCD block cursor on
  60.                  lcd.blink();
  61.                  break;
  62.          case  84: //LCD block cursor off
  63.                  lcd.noBlink();
  64.                  break;
  65.          case  88: //LCD display clear
  66.                  lcd.clear();
  67.                  break;
  68.          case 152: //LCD backlight brightness [brightness]
  69.                  analogWrite(3, getSerialByte()) ;
  70.                  break;
  71.        }
  72.        return;

  73.     }
  74.     lcd.print(getByte);
  75. }
複製代碼
Arduino BlueTooth LCD Smartie
Arduino BlueTooth LCD Smartie .jpg

Arduino BlueTooth LCD Smartie from PC BlueTooth USB Dongle 試機成功....

[ 本帖最後由 zonebaby 於 2009-10-1 02:07 編輯 ]

圖片附件: LCD Smartie Setup.gif (2009-10-1 02:07, 22.67 KB) / 下載次數 274
https://h2.hkepc.com/forum/attachment.php?aid=950687&k=a1c1c253c97c0fbc591c60bd3626bd4d&t=1781441225&sid=13lm4A3qwEr



圖片附件: LCD Smartie.gif (2009-10-1 02:07, 5.67 KB) / 下載次數 210
https://h2.hkepc.com/forum/attachment.php?aid=950688&k=8b16ee3f25031c900f425749e999bb2f&t=1781441225&sid=13lm4A3qwEr



圖片附件: Arduino BlueTooth LCD Smartie .jpg (2009-10-1 02:07, 252.44 KB) / 下載次數 223
https://h2.hkepc.com/forum/attachment.php?aid=950689&k=19763171eb3a8e89a5c859441dd747b2&t=1781441225&sid=13lm4A3qwEr


作者: 薯餅v.v    時間: 2009-9-27 16:40

試下配合lcd smartie 睇下得吾得
想知得吾得好耐不過冇錢買藍牙黎試
作者: zonebaby    時間: 2009-9-27 17:06

原帖由 薯餅v.v 於 2009-9-27 16:40 發表
試下配合lcd smartie 睇下得吾得
想知得吾得好耐不過冇錢買藍牙黎試


應該得,......計劃中.........
作者: 薯餅v.v    時間: 2009-9-27 17:11

原帖由 zonebaby 於 2009-9-27 17:06 發表


應該得,......計劃中.........

期待
作者: zonebaby    時間: 2009-10-1 02:08

原帖由 薯餅v.v 於 2009-9-27 17:11 發表

期待


試左個舊code可以直接用,但要改下D速度。可意睇下post#5。
作者: michael2010    時間: 2009-12-12 11:22


另外一點想知道就係用十幾蚊買粒usb bluetooth dongle
拆左佢強行用MCU控制有冇機會行得通
不過唔知係咪一黎入面粒chip 係bulit-in usb interface,再轉就好慢
有空會試一試
作者: asp88    時間: 2010-1-3 00:27

等闲我都玩下
作者: pc1697    時間: 2010-9-25 22:47

Serial.Read() 同Serial.print() 係唔係一定行 PIN0/1 TX/RX??
作者: 秋本裕太    時間: 2010-10-27 22:48

我想問問要在Arduino上加上什麼
才可以接收PC bluetooth use dongle發出的訊號
還有有沒有更詳細的有關方面的資料可以提供
非常感謝樓主
作者: zonebaby    時間: 2010-10-28 08:25

睇下有冇用.....
http://www.hkepc.com/forum/redir ... 37&pid=21151069
作者: KwokAngus    時間: 2011-3-9 00:37

可唔可以用黎試玩遙控摩打
作者: prof2034    時間: 2012-6-28 09:27

之前試來試去都無data到bt,昨日試下把bt的接電重置.就正確連到,bt上的led會常亮.原因不明.有d似我地用藍牙耳機,有時要重開才可連接.
作者: 魚蛋Strike    時間: 2016-8-5 23:34

八下....
咁.... 用手機send BT呢?
又...用手機send BT, 去 Arduino 出rs232 command 要點玩呢?

作者: rmhc    時間: 2019-1-21 15:57

提示: 作者被禁止或刪除 內容自動屏蔽





歡迎光臨 電腦領域 HKEPC Hardware (https://h2.hkepc.com/forum/) Powered by Discuz! 7.2