Go Down

Topic: bluetooth serial port issues (Read 939 times) previous topic - next topic

dennischen


I have a bluetooh problem.
1.My hardware: Bluetooh Bee module, Arduino board, Eee PC
2.My Software: Accessport, Arduino IDE
3.My sketch:

char val; // variable to receive data from the serial port
int ledpin = 8; // LED connected to pin 48 (on-board LED)
void setup() {
  pinMode(ledpin, OUTPUT);  // pin 48 (on-board LED) as OUTPUT
  Serial.begin(9600);       // start serial communication at 9600bps
}
void loop() {
  if( Serial.available() )       // if data is available to read
  {
    val = Serial.read();         // read it and store it in 'val'
  }
  if( val == 'H' )               // if 'H' was received
  {
    digitalWrite(ledpin, HIGH);  // turn ON the LED
    Serial.println('H', BYTE);
  } else {
    digitalWrite(ledpin, LOW);   // otherwise turn it OFF
   Serial.println('L',BYTE);
  }
  delay(100);                    // wait 100ms for next reading
}

4.My issues:
   The LED can be turn on when I enter 'H' via Accessport, but I can't see the response character on Accessport. I make sure the baud rate(Accessport) is 9600 on COM8(bluetooth serial port).
Can anyone give me hints to solve this issue?




dennischen


I solved my issues, but have another question,
  Serial.read() is getting data from BT, but Serial.print() is not sending data out via BT, why?

Go Up