hello,
I am newbie in electronic and arduino.
I am facing this problem for more than 1 week.
I hope someone can give me ideas on how to move forward.
My plan:
Using PC communicate with arduino UNO pin Tx & Rx via bluetooth.
Everything is good,
I can make use of hyperterminal to receive a looping counter value from arduino program.
I try to type 'H' to turn on/off the LED on arduino UNO.
I am going to narrow down the problem.
Is it a bluetooth module problem?
Is it a Rx pin problem of UNO?
Pls. give me some advise.
How about this?
If I remove the bluetooth module, like using a USB<--> TTL cable,
connect the Tx pin to UNO Rx, Rx pin to UNO Tx pin.
Then, using hyperterminal to connect this com port.
Can i test the TxRx function of UNO?
Or, any other method that i can test on it?
Thank you.
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
} else {
digitalWrite(ledpin, LOW); // otherwise turn it OFF
}
delay(100); // wait 100ms for next reading
Pls mind some BT modules have got "sleep" mode implemented (as mine did) - after 6secs of inactivity they go to sleep, waking up takes some time, so your characters are lost