From ElectroDragon Wiki


Arduino Demo Code

//arduino uno wiring
//BLE4.0   UNO

int LED = 13;

void setup()
  	Serial.begin(115200);		// baudrate 115200
  	while (!Serial); // wait for serial port to connect. Needed for Leonardo only

void loop()
  if (Serial.available() > 0) {
    char inChar = (char); 	//read serial port data read serial port data
    Serial.write(inChar);				//send back received data, if the phone app can read the return data means the communication is working well

    if(inChar == 'B'){
    	digitalWrite(LED,HIGH);			//led on when press button B
    else if(inChar == 'R'){
    	digitalWrite(LED,LOW);			//led off when press button R