Quantcast
Channel: Seeedstudio Forum
Viewing all articles
Browse latest Browse all 6612

Possible to Upload Code to Arduino Using Bluetooth Shield?

$
0
0
In case it helps, the current code is:

Code:#include <SoftwareSerial.h>   //Software Serial Port
#define RxD 6
#define TxD 7
#define DEBUG_ENABLED  1
SoftwareSerial blueToothSerial(RxD,TxD);
int led = 13;
void setup()
{
  Serial.begin(9600);
  pinMode(led, OUTPUT); // led onboard arduino uno pin 13
  pinMode(RxD, INPUT);
  pinMode(TxD, OUTPUT);
  setupBlueToothConnection(); 
}

void loop()
{
  char recvChar; 
  if(blueToothSerial.available()){//check if there's any data sent from the remote bluetooth shield
    recvChar = blueToothSerial.read();
    Serial.print(recvChar);
  }
  if(Serial.available()){//check if there's any data sent from the local serial terminal, you can add the other applications here
    recvChar  = Serial.read();
    blueToothSerial.print(recvChar);
  } 
  // ADD Code HERE:
  if (recvChar == '0' ) // if input from serial is = 0
  {
    digitalWrite(led, LOW); // turn off led on arduino uno pin 13
    delay(45);
  }
  if (recvChar == '1') // if input from serial is = 1
  {
    digitalWrite(led, HIGH); // turn on led on arduino uno pin 13
    delay(45);
  }

void setupBlueToothConnection()
{
  blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to 38400 ..default baud rate 38400 (btShield plays nicely at default baud rate)
  blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
  blueToothSerial.print("\r\n+STNA=SeeedBT\r\n"); //set the bluetooth name as "SeeedBT"
  blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
  blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
  blueToothSerial.print("\r\n+STPIN=0000\r\n");//set pin to 0000
  //blueToothSerial.print("\r\n+RTPIN=0000\r\n");// ask to input pin
  //blueToothSerial.print("\r\n+DLPIN\r\n");
  delay(2000); // This delay is required.
  blueToothSerial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
  Serial.println("The slave bluetooth is inquirable!");
  delay(2000); // This delay is required.
  //blueToothSerial.print("\r\n+CONN=00,16,a4,06,b5,47\r\n");
  //delay(2000);
  blueToothSerial.flush();
}


And I am currently just interfacing with an Arduino Uno R3 (ATMega 328)

Statistics : Posted by bdgb78 • on Sun Mar 30, 2014 4:48 am • Replies 1 • Views 13

Viewing all articles
Browse latest Browse all 6612

Trending Articles