Pages: [1]   Go Down
Author Topic: Bluetooth Shield COM problem  (Read 768 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 96
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
« Last Edit: September 25, 2012, 03:08:25 am by zuzzuz » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 640
Posts: 50335
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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?
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 96
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: