2014年11月5日 星期三

Arduino + Android + 藍芽 + MIT App

Arduino  +  Android  + 藍芽 + MIT App  練習

參考 
http://blog.cavedu.com/appinventor-%E5%9C%96%E5%BD%A2%E5%8C%96android/appinventorandarduinowithbluetooth/#prettyPhoto







#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
  } //for 
  }//while
}

沒有留言:

張貼留言

Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3

  Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3 AngularJS 實例 <!DOCTYPE html> <html> <head> <meta charse...