hi everybody! (again!)
the things have been going great lately with Arduino / Bluetooth Shield, but I had some problems with the computer’s Bluetooth device (minor things) but no luck transmitting data.
I am using the following code for the arduino (is the adaptation of one I found on Instructables)(to control the motors I’m using an equivalent circuit "L298 Dual H-Bridge Motor Driver":
[code]#include <NewSoftSerial.h> //Software Puerto Serial BT
#define DEBUG_ENABLED 1
#define RxD 6
#define TxD 7
NewSoftSerial BTSerial(RxD,TxD);
int m1_c = 3;
int m1_d = 4;
int m1_pwm = 5;
int m2_c = 11;
int m2_d = 12;
int m2_pwm = 10;
int DatoLeidoBT = 0;
void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();
pinMode(m1_c, OUTPUT);
pinMode(m1_d, OUTPUT);
pinMode(m1_pwm, OUTPUT);
pinMode(m2_c, OUTPUT);
pinMode(m2_d, OUTPUT);
pinMode(m2_pwm, OUTPUT);
digitalWrite(m1_pwm, HIGH);
digitalWrite(m2_pwm, HIGH);
parar();
delay(500);
}
void loop(){
if (BTSerial.available() > 0) {
DatoLeidoBT = BTSerial.read();
BTSerial.print("Recibi: ");
BTSerial.println(DatoLeidoBT);
Serial.print("Recibi: ");
Serial.println(DatoLeidoBT);
delay(10);
if (DatoLeidoBT == 119){
adelante();
delay(25);
}
else if (DatoLeidoBT == 97){
izquierda();
delay(25);
}
else if (DatoLeidoBT == 100){
derecha();
delay(25);
}
else if (DatoLeidoBT == 115){
atras();
delay(25);
}
else {
parar();
}
}
else {
parar();
}
}
void adelante(){
digitalWrite(m1_c, HIGH);
digitalWrite(m1_d, LOW);
digitalWrite(m2_c, HIGH);
digitalWrite(m2_d, LOW);
}
void atras(){
digitalWrite(m1_c, LOW);
digitalWrite(m1_d, HIGH);
digitalWrite(m2_c, LOW);
digitalWrite(m2_d, HIGH);
}
void derecha(){
digitalWrite(m1_c, HIGH);
digitalWrite(m1_d, LOW);
digitalWrite(m2_c, LOW);
digitalWrite(m2_d, HIGH);
}
void izquierda(){
digitalWrite(m1_c, LOW);
digitalWrite(m1_d, HIGH);
digitalWrite(m2_c, HIGH);
digitalWrite(m2_d, LOW);
}
void parar(){
digitalWrite(m1_c, LOW);
digitalWrite(m1_d, LOW);
digitalWrite(m2_c, LOW);
digitalWrite(m2_d, LOW);
}
void setupBlueToothConnection()
{
BTSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
BTSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
BTSerial.print("\r\n+STNA=ArdubotBT\r\n"); //set the bluetooth name as “ArdubotBT”
BTSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
BTSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
delay(2000); // This delay is required.
BTSerial.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.
BTSerial.flush();
}
[/code]
after upload the code, I open the program SSCOM32E and try send data to the arduino but does not react.
one could guide me a little how I can transmit data from the computer COM port of the bluetooth device
I would greatly appreciate your help!