Skip to content

Instantly share code, notes, and snippets.

@adrianstevens
Created November 11, 2014 05:40
Show Gist options
  • Save adrianstevens/06e3dc722a05d8da837e to your computer and use it in GitHub Desktop.
Save adrianstevens/06e3dc722a05d8da837e to your computer and use it in GitHub Desktop.
Seeed Grove BLE with Intel Edison UART (2 way serial)
int incomingByte = 0; // for incoming serial data
const int pinButton = 6; // pin of button define here
const int pinLed = 3; // pin of led define here
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("hello");
pinMode(pinButton, INPUT); // set button INPUT
pinMode(pinLed, OUTPUT); // set led OUTPUT
setupBleConnection();
}
void setupBleConnection()
{
Serial1.begin(9600); //Set BLE BaudRate to default baud rate 9600
Serial1.print("AT+CLEAR"); //clear all previous setting
Serial1.print("AT+ROLE0"); //set the bluetooth name as a slaver
Serial1.print("AT+SAVE1"); //don't save the connect information
}
void loop ()
{
char recvChar;
while(1)
{
if(Serial.available())
{
recvChar = Serial.read();
Serial1.print(recvChar);
digitalWrite(pinLed, HIGH); // led on
}
if(Serial1.available())
{
recvChar = Serial1.read();
Serial.print(recvChar);
digitalWrite(pinLed, HIGH); // led on
}
digitalWrite(pinLed, LOW); // led off
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment