Serial data is not sent on interrupt I have a short program which should receive data, use this data to turn on/off an LED, and send data when a button is pressed. It is deployed on a Digispark board. The button is connected to INT0 port (PB2). The interrupt works, but data is not send. Receiving data works fine.

What am I missing here?

#include &lt;SoftSerial.h&gt;

#define RxD 1
#define TxD 0
#define out 3
#define btn 2
#define testled 4

SoftSerial blueToothSerial(RxD, TxD); //RX, TX
volatile int buttonState = 0;

void setup() {
  pinMode(out, OUTPUT);
  pinMode(btn, INPUT);
  pinMode(testled, OUTPUT);
  setupBlueToothConnection();
  digitalWrite(out, HIGH);
  digitalWrite(testled, HIGH);
  attachInterrupt(0, intrpt, CHANGE);
}

void loop() {    
  char newVal;
  if(blueToothSerial.available()){
    newVal = blueToothSerial.read();
    if (newVal == '1') {
      digitalWrite(out, HIGH);
    } else {
      digitalWrite(out, LOW);
    }
  }
}

void intrpt() {
  buttonState = digitalRead(btn);
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(testled, HIGH);
  } else {
    // turn LED off:
    digitalWrite(testled, LOW);
    blueToothSerial.println("0");
  }
}

void setupBlueToothConnection() {
  blueToothSerial.begin(9600); 
  blueToothSerial.print("\r\n+STWMOD=0\r\n"); 
  blueToothSerial.print("\r\n+STNA=HC-05\r\n"); 
  blueToothSerial.print("\r\n+STOAUT=1\r\n"); 
  blueToothSerial.print("\r\n+STAUTO=0\r\n");    
  delay(2000);    
  blueToothSerial.print("bluetooth connected!\n");    
  delay(2000); 
  blueToothSerial.flush();
}


EDIT

Serial data is sent fine. The above code works. On Windows I can see the data are coming, but not on OS X.
If you are handling interrupts then you need to keep the code as quick and simple as possible.  I suspect that in this case calling blueToothSerial.println is what's causing the problem. It may well be calling an operation that an ISR can't call and so it fails and your code doesn't write the data you expect it to.

All I ever do in ISRs is set flags and then get the 'normal' code to handle changes to the flags. Personally I wouldn't do the digitalWrites within the ISR. Have two volatile variables, one for the pin state and one when sending a message is required and handle those in your loop().