BTduino - Arduino - Bluetooth 1.7

Giấy phép: Miễn phí ‎Kích cỡ tệp: 1.05 MB
‎Xếp hạng người dùng: 0.0/5 - ‎0 ‎Phiếu

BTduino 是利用手機藍芽裝置(Bluetooth)連接 Arduino 的應用程式。此程式現提供數字按鍵模式及遊戲控制器模。往後亦會加入PWM,各種感應器及按鍵配對等功能。使用者需連接藍芽接收裝置如HC06至Arduino。藍芽HC06連接Arduino的設置如下: 1. 藍芽VCC接Arduino 5v或3.3v(視乎所購買的裝置而定) 2. 藍芽GND接Arduino GND 3. 藍芽RXD接Arduino TX(Pin10) 4. 藍芽TXD接Arduino RX(Pin11) Arduino RX (Pin 11) kết nối với Bluethooth TX, Arduino TX (Pin 10) kết nối với Bluethooth RX

Arduino 設定 /* btduino2 - Terminal Mode - bởi David Chung */ #include

Phần mềmSerial myBT(11, 10); const int ledPin = 13; Chuỗi inCode = ""; boolean endCode = sai;

thiết lập khoảng trống() { Serial.begin(9600); myBT.begin(9600); pinMode (ledPin, ĐẦU RA); inCode.reserve(50); }

khoảng trống loop() { nếu (myBT.available()) { char incomingChar = myBT.read(); if(incomingChar == ')'){ endCode = đúng; } khác { inCode += incomingChar; } }

nếu (endCode){ int strEnd = inCode.indexOf(')'); Chuỗi myString = inCode.substring(0, strEnd);

Serial.print("Đến : "); Serial.println(myString); if(myString == "bật"){ digitalWrite (ledPin, CAO); myBT.print("LED On"); } if(myString == "tắt"){ digitalWrite (ledPin, LOW); myBT.print("LED Tắt"); } inCode = ""; endCode = sai; } }

/* btduino2 - Chế độ GamePad - bởi David Chung */ #include

Phần mềmSerial myBT(11, 10); const int ledPin = 13; int incomingByte = 0;

thiết lập khoảng trống() { Serial.begin(9600); myBT.begin(9600); pinMode (ledPin, ĐẦU RA); }

khoảng trống loop() { nếu (myBT.available()) { incomingByte = myBT.read(); Serial.println(char(incomingByte)); if(incomingByte == 'L'){ nếu(incomingByte == 'L'){ digitalWrite (ledPin, CAO); } if(incomingByte == 'R'){ nếu(incomingByte == 'R'){ digitalWrite (ledPin, LOW); } } }

/* Chế độ Con trượt */ #include

Phần mềmSerial myBT(11, 10); const int ledPin = 13; Chuỗi inCode = "";

boolean endCode = sai;

thiết lập khoảng trống() { Serial.begin(9600); myBT.begin(9600); pinMode (ledPin, ĐẦU RA); inCode.reserve(30); }

khoảng trống loop() { nếu (myBT.available()) { char incomingChar = myBT.read(); if(incomingChar == ')'){ endCode = đúng; } khác { inCode += incomingChar; } }

nếu (endCode){ int dấu phẩy1 = inCode.indexOf(','); int comma2 = inCode.indexOf(',', dấu phẩy1 + 1); Chuỗi Rs = inCode.substring(0, dấu phẩy1); String Gs = inCode.substring(dấu phẩy1 + 1, dấu phẩy2); Chuỗi Bs = inCode.substring(dấu phẩy2 + 1);

Serial.print("inCode = "); Serial.print(inCode); Serial.print(" R = "); Serial.print(Rs); Serial.print(" G = "); Serial.print(Gs); Serial.print(" B = "); Serial.println (Bs);

int R = Rs.toInt(); int G = Gs.toInt(); int B = Bs.toInt();

analogWrite (ledPin, R); inCode = ""; endCode = sai; } }

/* btduino2 - Chế độ định hướng - bởi David Chung */ #include

Phần mềmSerial myBT(11, 10); const int ledPin = 13; Chuỗi inCode = ""; boolean endCode = sai;

thiết lập khoảng trống() { Serial.begin(9600); myBT.begin(9600); pinMode (ledPin, ĐẦU RA); inCode.reserve(30); }

khoảng trống loop() { nếu (myBT.available()) { char incomingChar = myBT.read(); if(incomingChar == ')'){ endCode = đúng; } khác { inCode += incomingChar; } }

nếu (endCode){ int dấu phẩy1 = inCode.indexOf(','); int comma2 = inCode.indexOf(',', dấu phẩy1 + 1); Chuỗi As = inCode.substring(0, dấu phẩy1); Chuỗi Ps = inCode.substring(dấu phẩy1 + 1, dấu phẩy2); Chuỗi Rs = inCode.substring(dấu phẩy2 + 1);

Serial.print("inCode = "); Serial.print(inCode); Serial.print(" Phương vị = "); Serial.print(Như); Serial.print(" Pitch = "); Serial.print(Ps); Serial.print(" Cuộn = "); Serial.println (Rs);

int A = As.toInt(); int P = Ps.toInt(); int R = Rs.toInt();

inCode = ""; endCode = sai; } }

lịch sử phiên bản

  • Phiên bản 1.7 đăng trên 2015-11-30
    修正 Phương thức định hướng輸出值

Chi tiết chương trình