arduino uno上传代码:
int i ;
void setup() {
Serial.begin(115200);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
if (Serial.available())
{
// Serial.write(Serial.read());
i = Serial.read();
// Serial.println(i);
Serial.write(i);
Serial.write('\n');
}
if (i == 'a')
{
digitalWrite(2, HIGH);
}
if (i == 'b')
{
digitalWrite(3, HIGH);
}
if (i == 'c')
{
digitalWrite(4, HIGH);
}
}
esp32cam上传代码:
//This example code is in the Public Domain (or CC0 licensed, at your option.)
//By Evandro Copercini - 2018
//
//This example creates a bridge between Serial and Classical Bluetooth (SPP)
//and also demonstrate that SerialBT have the same functionalities of a normal Serial
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;
char i;
void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32test"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop() {
// 蓝牙助手发送数据到电脑串口
if (SerialBT.available()) {
while (SerialBT.available()) {
// Serial.write(SerialBT.read());
//读一个就少一个
i = SerialBT.read();
Serial.print(i);
}
}
}