Go Down

Topic: Bluetooth Shield COM problem (Read 842 times) previous topic - next topic

zuzzuz

Sep 25, 2012, 09:35 am Last Edit: Sep 25, 2012, 10:08 am by zuzzuz Reason: 1
Hi, i have this shield http://iteadstudio.com/store/index.php?main_page=product_info&cPath=18&products_id=307
I can't have data back from BT COM, for test i used this sketch
Code: [Select]
unsigned int timeout=0;
unsigned char state=0;

ISR(TIMER2_OVF_vect)          //Timer2  Service
{
 TCNT2 = 0;
 timeout++;
 if (timeout>61)
 {
   state=1;
   timeout=0;
 }

}

void init_timer2(void)              
{
 TCCR2A |= (1 << WGM21) | (1 << WGM20);  
 TCCR2B |= 0x07;   // by clk/1024
 ASSR |= (0<<AS2);  // Use internal clock - external clock not used in Arduino
 TIMSK2 |= 0x01;   //Timer2 Overflow Interrupt Enable
 TCNT2 = 0;
 sei();  
}

void setup()
{
 Serial.begin(9600);
 pinMode(2,INPUT);
 pinMode(13,OUTPUT);
 attachInterrupt(0,cleantime,FALLING);
 init_timer2();
}

void loop()
{
 switch(state)
 {
 case 0:
   digitalWrite(13,LOW);
   break;

 case 1:
   digitalWrite(13,HIGH);
   Serial.print("Hellow BT");
   break;

 }

}

void cleantime()
{
 timeout=0;
 state=0;
}


This is what i see from my computer

As u can see USB port is OK but COM9 data is bad
Have someone the same shield? Can someone help me?
Thx bye

PaulS

Code: [Select]
unsigned char state=0;

ISR(TIMER2_OVF_vect)          //Timer2  Service
{
    state=1;
}

void loop()
{
  switch(state)
  {
  }
}

void cleantime()
{
  state=0;
}


And, yet, state is not declared volatile. Is there a reason for that?

Ditto for timeout.

Finally, forgive me for asking what might be a really obvious question. Why are you creating such a complex sketch to test whether the bluetooth device works?

zuzzuz

This is test sketch that i found in documentation of this shield.
I solved my problem changing my BT adapter, i think my old adapter was dead.
Thx

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy