Bluetooth trigger on connect and disconnection

I'm wondering if anyone has any ideas on getting the arduino uno to see Bluetooth send out a + or - one second trigger. then on lost connection send out same on another pin. I am a novice. know the bare minimum. But am trying to learn. Its essentially gonna be for a car lock unlock system. I can then use relays or idatalink module to control door locks. Any ideas would be helpful.thanks

I don't think Aduino can see the connection but it might be able to be told.

The bluetooth is just a serial device at the other end of the cable, Arduino doesn't know what it is, doesn't know if it is doing anything, and doesn't care either. It can be programmed to listen for data but it wouldn't know if a deafening silence means nobody wants to say anything, or simply that bluetooth is disconnected.

Bluetooth does know when it is disconnected, and typically flashes an LED to that effect. It therefore follows that the signal for the LED can sent to a pin on Arduino, which might be sufficient for you to do what you want to do.

The above applies to a plain-vanilla HC-0x module but it likely to be typical.

maybe i could use a bluetooth serial app and tasker to trigger the aurdino? I see that my hc06 has a 'state' output could that be useful? I metered the state pin and when led is blinking it fluctuates when connected to phone it its steady voltage. Is there a sketch i can use to test if my aurdino is seeing this input

If you are referring to a proper pin, it sounds like an HC-05. This connects to pin 31 on the module, while the LED is on pin 24 on the HC-06. Either way, it is the sort of thing I had in mind - pass a signal to Arduino. Arduino should be able to read 3.3v from it OK, that is all it gets from Bluetooth Tx. The button example in the IDE should have all you need and I imagine there is plenty of stuff on the playground

Here is a demo code for Bluetooth State LED, tested with BT Shield v2.1 (slave) which has State LED connected to pin 2 interrupt.

BT Shield v2.1 slave Wiki

volatile int IRQcount;
int result;
int pin = 2;
int pin_irq = 0; //IRQ that matches to pin 2

void setup() {
  // put your setup code here, to run once:
  Serial.begin (9600);
  attachInterrupt(pin_irq, IRQcounter, RISING);

void IRQcounter() {
void count() {
  cli();//disable interrupts
  IRQcount = 0;
  sei();//enable interrupts
  cli();//disable interrupts
  result = IRQcount;
  sei();//enable interrupts
  Serial.print(F("Counted LED Blink: "));
void ifCount() {
  if (result == 0) {
    Serial.println(F("LED On or Off"));
    Serial.println(F(" "));
    else if (result >= 1) {
    Serial.println(F("LED Blink")); // 1 blink or more
    Serial.println(F(" "));
void loop() {