|
代码功能:
1.与适配器4.0蓝牙连接
2.蓝牙串口传输
#include "BLESerial.h"
const int BUTTON=4;
void setup() {
pinMode(13, OUTPUT);
pinMode(6, OUTPUT);
int BUTTON=4;
pinMode(BUTTON, INPUT);
Serial.begin(115200); // initialize serial communication
Serial1.begin(115200);
BLESerial.setName("Bluno101");
BLESerial.begin();
//Serial.println("Bluetooth device active, waiting for connections...");
while(!BLESerial);
}
void loop() {
while (BLESerial.operator bool()) {
digitalWrite(13,HIGH);
if(BLESerial.available()){
BLESerial.write(BLESerial.read());
}
if(digitalRead(BUTTON)){
digitalWrite(6,HIGH);
BLESerial.write("dengliang");
BLESerial.println();
}
else{
digitalWrite(6, LOW);
}
}
digitalWrite(13, LOW);
}
|
|