0

請問一下... 我使用softserial 的方式去抓 Hc-05....

按照例子跑沒有問題...

但是當我使用D6 來當作output pin....

此時就會有問題... 我明明就沒有傳送data 到HC-05...但是softserial 那邊就一直收到0 的資料

 

請問這個issue有解嘛?

 

#include <SoftwareSerial.h>

SoftwareSerial blueToothSerial(0, 1); // RX, TX

int AIN2=4;
int AIN1=5;

// for motor 1
int BIN2=6;
int BIN1=7;

// for motor 0
//int MOTOR_ENA=8;

int MOTOR_ENA=11;

// for motor 1
int MOTOR_ENB=9;

void setup() {
//pinMode(AIN1, OUTPUT);
//pinMode(AIN2, OUTPUT);
//pinMode(BIN1, OUTPUT);
pinMode(BIN2, OUTPUT);
// pinMode(MOTOR_ENA, OUTPUT);
//pinMode(MOTOR_ENB, OUTPUT);

// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Goodnight moon!");

// set the data rate for the SoftwareSerial port
blueToothSerial.begin(9600);
//mySerial.println("Hello, world?");
}

void loop() { // run over and over
if (blueToothSerial.available()) {
Serial.print(blueToothSerial.read());
}
}

williamlai 回答了