So currently I’m in my capstone class and coming up in just under a week now I have to have successfully uploaded code to a robot powered by an arduino. So we bought a Seeedstudio Bluetooth Shield. For a while I could not get it to work at all. However now I have been successfully able to get it to pair with the Bluetooth USB dongle that we have. But now I can’t figure out how to possibly upload the code. Currently I’m just trying to reupload the same code every time and not using any of the code for the robot itself but just for the bluetooth.
#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)