-
StackOverflow 文件
-
arduino 教程
-
藍芽通訊
-
基本的藍芽 Hello World
#include <SoftwareSerial.h>
// its always better to change the default tx and rx as the may interfere with other process in future.
// configure tx , rx by defualt they will be 0 and 1 in arduino UNO
SoftwareSerial blue(3,2);
void setup() {
// preferred baud rate/data transfer rate in general is 38400
blue.begin(38400);
// do initialization or put one time executing code here
}
void loop() {
// put code that you want it to run every time no matter what
if(blue.available()){
// put only that code which needsd to run when there is some data
// This means that the their is some data sent over the bluetooth
// You can do something with the data
int n;
// consider that the data received to be integer, read it by using blue.parseInt();
n = blue.parseInt();
}
}