Go Down

Topic: Help seeed bluetooth shield (Read 2111 times) previous topic - next topic

CCJAD

I recently just purchased the Seeed bluetooth shield from Radioshack (http://www.radioshack.com/product/index.jsp?productId=12688459)i am using Arduino UNO R3 .I found this http://www.seeedstudio.com/wiki/Bluetooth_Shield but it didn't really help me i installed the two libraries and up loaded slave but it didnt work it came up with an error . I spent three days trying to figure out how to use it but I'm so lost could someone please help me? it would be much appreciated.

PaulS

Quote
i installed the two libraries and up loaded slave but it didnt work it came up with an error .

Which you are not interested in fixing, apparently, or you would have told us what it was. And posted the code.

CCJAD

Sorry the error is

Slave:37: error: 'NewSoftSerial' does not name a type
Slave.pde: In function 'void loop()':
Slave:52: error: 'blueToothSerial' was not declared in this scope
Slave:58: error: 'blueToothSerial' was not declared in this scope
Slave.pde: In function 'void setupBlueToothConnection()':
Slave:65: error: 'blueToothSerial' was not declared in this scope

this is the code im using im not the best coder so idk whats wrong i have the board setup just like on the wiki page

Code: [Select]
/*
BluetoothShield Demo Code Slave.pde. This sketch could be used with
Master.pde to establish connection between two Arduino. It can also
be used for one slave bluetooth connected by the device(PC/Smart Phone)
with bluetooth function.
2011 Copyright (c) Seeed Technology Inc.  All right reserved.

Author: Steve Chang

This demo code is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

For more details about the product please check http://www.seeedstudio.com/depot/

*/


/* Upload this sketch into Seeeduino and press reset*/

#include <SoftwareSerial.h>   //Software Serial Port
#define RxD 6
#define TxD 7

#define DEBUG_ENABLED  1

NewSoftSerial blueToothSerial(RxD,TxD);

void setup()
{
  Serial.begin(9600);
  pinMode(RxD, INPUT);
  pinMode(TxD, OUTPUT);
  setupBlueToothConnection();

}

void loop()
{
  char recvChar;
  while(1){
    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);
    }
  }
}

void setupBlueToothConnection()
{
  blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
  blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
  blueToothSerial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave"
  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
  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.flush();
}




PaulS

What version of the IDE are you using? Prior to 1.0, NewSoftSerial was a user downloaded library. With 1.0 and on, NewSoftSerial was adopted as an official library, and renamed SoftwareSerial.

CCJAD

ok so i went in total nerd mode missed a day of school spent the whole day to figure this out . so i used this code that i changed a little bit 

Code: [Select]


//Author: Steve Chang

#include <SoftwareSerial.h>   //Software Serial Port
#define RxD 6
#define TxD 7

#define DEBUG_ENABLED  1
const int right = 8;
const int left = 9;
const int headlight = 10;
const int pingPin = 11;
int incomingByte;


SoftwareSerial blueToothSerial(RxD,TxD);

void setup()
{
  Serial.begin(9600);
  pinMode(RxD, INPUT);
  pinMode(TxD, OUTPUT);
  pinMode(right, OUTPUT);
  pinMode(left, OUTPUT);
  pinMode(headlight, OUTPUT);
  setupBlueToothConnection();

}

void loop()
{
  char recvChar;
  while(1){
    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);
    }
    if (recvChar == 'F') {
      digitalWrite(right, LOW);
      digitalWrite(left, LOW);
    }
    // if it's an L (ASCII 76) turn off the LED:
    if (recvChar == 'L') {
      digitalWrite(right, LOW);
      digitalWrite(left,HIGH);
    }
    if(recvChar == 'R') {
      digitalWrite(right,HIGH);
      digitalWrite(left, LOW);
    }
    if(recvChar == 'S') {
      digitalWrite(right, HIGH);
      digitalWrite(left, HIGH);
    }
    if(recvChar == 'J') {
      digitalWrite(headlight, HIGH);
    }
    if(recvChar == 'K') {
      digitalWrite(headlight, LOW);
    }
  }
}

void setupBlueToothConnection()
{
  blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
  blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
  blueToothSerial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave"
  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
  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.flush();
}


this is the original code

Code: [Select]


/*
BluetoothShield Demo Code Slave.pde. This sketch could be used with
Master.pde to establish connection between two Arduino. It can also
be used for one slave bluetooth connected by the device(PC/Smart Phone)
with bluetooth function.
2011 Copyright (c) Seeed Technology Inc.  All right reserved.

Author: Steve Chang

This demo code is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

For more details about the product please check http://www.seeedstudio.com/depot/

*/


/* Upload this sketch into Seeeduino and press reset*/

#include <SoftwareSerial.h>   //Software Serial Port
#define RxD 6
#define TxD 7

#define DEBUG_ENABLED  1

NewSoftSerial blueToothSerial(RxD,TxD);

void setup()
{
  Serial.begin(9600);
  pinMode(RxD, INPUT);
  pinMode(TxD, OUTPUT);
  setupBlueToothConnection();

}

void loop()
{
  char recvChar;
  while(1){
    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);
    }
  }
}

void setupBlueToothConnection()
{
  blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
  blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
  blueToothSerial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave"
  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
  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.flush();
}



See i changed NewSoftSerial blueToothSerial(RxD,TxD); to SoftwareSerial blueToothSerial(RxD,TxD);
and i put all my other code in the while statement and changed the incomingByte/Serial.read to recvChar in the if statement
and now every thing is working nice that code is the code i used on my first wireless non autonomous robot  XD

PaulS

Quote
and now every thing is working nice

Great. Now, get rid of the infinite loop (while(1) {}) inside the infinite loop (loop()).

CCJAD

:( ok now i have another problem i was doing good then i took a break for like a week came back
uploaded my edited sketch and now my phone detects the the seed slave it then says "connecting..."
then "Bluetooth serial port connection fail."

Go Up