Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- #include <Wire.h> //引用二個函式庫SoftwareSerial及Wire SoftwareSerial
- SoftwareSerial I2CBT(10,11); //定義PIN10及PIN11分別為RX及TX腳位
- void setup() {
- Serial.begin(9600); //Arduino起始鮑率9600
- I2CBT.begin(57600); //藍牙鮑率57600
- //(注意!此鮑率每個藍牙晶片不一定相同,請先確認完再填寫進去)
- }
- void loop() {
- byte cmmd[20];
- int insize;
- while(1){
- 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.println(" ");
- }//if
- Serial.print("end one time\n");
- } //for
- }//while
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement