5_STM32duino_CC2541(BLE),

1_CC2541(BLE)

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,9);
int ledpin=A6;

void setup() {
mySerial.begin(9600);
Serial.begin(9600);
pinMode(ledpin,OUTPUT);
}

void loop() {
int i;

if (mySerial.available())
{
  
i=mySerial.read();
Serial.println("DATA RECEIVED:");

if(i=='1')
{
digitalWrite(ledpin,1);
Serial.println("led on");
}

if(i=='0')
{
digitalWrite(ledpin,0);
Serial.println("led off");
}

}
}
複製代碼

本站公眾號
   歡迎關注本站公眾號,獲取更多信息