SoftwareSerial mySerial(4,5);
#利用此函数设置软串口的RX,TX
切记在setup()中 设置波特率
mySerial.begin(9600);
然后读取缓冲区字符串操作如下
char getpass[4];
int numdata=0;
while (mySerial.available()>0)
{
numdata =mySerial.readBytesUntil(character,getpass,4);
Serial.print(getpass);
if(!(strncmp(getpass, initial_password,4)))
{
Serial.println("Pass Accepted");
digitalWrite(relay_pin, LOW);
delay(2000);
Serial.println("Enter Password:");
}
}