You Reply: I tried the serial.print("Hello World") test with the Arduino IDE and had no success with the serial monitor. Win7 detects the bluetooth device on COM6 and I set the serial port to COM 6 when it's not gray. I retried several times with no success.
I downloaded a free version of Hyperterminal, but could not connect. Then I downloaded PuTTY and that worked, I got the Hello World transmissions.
So next I tried a simple program to transmit commands from the pc keyboard to the Romeo. However, this didn't work. The Romeo reacts to the commands but not in the correct way. This code doesn't send anything to digital pin 9 or 10 but some servos that are connected move when I type "w". According to the code, the dc motors connected t pins 4-7 are supposed to move. (This hardware has been tested and works without bluetooth) When I right click the mouse the motors toggle forward/backward a few times.
Here's the code that I'm using:
//Standard PWM DC control
int E1 = 5; //M1 Speed Control
int E2 = 6; //M2 Speed Control
int M1 = 4; //M1 Direction Control
int M2 = 7; //M1 Direction Control
void stop(void) //Stop
{
digitalWrite(E1,LOW);
digitalWrite(E2,LOW);
}
void advance(char a,char b) //Move forward
{
analogWrite (E1,a); //PWM Speed Control
digitalWrite(M1,HIGH);
analogWrite (E2,b);
digitalWrite(M2,HIGH);
}
void back_off (char a,char b) //Move backward
{
analogWrite (E1,a);
digitalWrite(M1,LOW);
analogWrite (E2,b);
digitalWrite(M2,LOW);
}
void turn_L (char a,char b) //Turn Left
{
analogWrite (E1,a);
digitalWrite(M1,LOW);
analogWrite (E2,b);
digitalWrite(M2,HIGH);
}
void turn_R (char a,char b) //Turn Right
{
analogWrite (E1,a);
digitalWrite(M1,HIGH);
analogWrite (E2,b);
digitalWrite(M2,LOW);
}
void setup(void)
{
int i;
for(i=4;i<=7;i++)
pinMode(i, OUTPUT);
Serial.begin(9600); //Set Baud Rate
}
void loop(void)
{
char val = Serial.read();
if(val!=-1)
{
switch(val)
{
case 'w'://Move Forward
advance (100,100); //PWM Speed Control
break;
case 's'://Move Backward
back_off (100,100);
break;
case 'a'://Turn Left
turn_L (100,100);
break;
case 'd'://Turn Right
turn_R (100,100);
break;
}
delay(40);
}
else stop();
}
Any ideas on what could be wrong with the bluetooth transmitted key commands?