how do i make my arduino reset when bluetooth lost signal...


i used hc-06 bluetooth module , arduino uno i'm using on bike wanted make bike off when phone out of range.. i' dont know how it. tryed searching no luck..

heres code...

code: [select]
/*
simple led test
*/

char val;         // variable receive data serial port
const byte relay1 = 2;  // led connected pin 2 (on-board led)
const byte relay2 = 3;

void setup()
{
  pinmode(relay1, output); // pin 2 () output
  pinmode(relay2, output); // pin 3 (on-board led) output
  digitalwrite(relay1, high);
  digitalwrite(relay2, high);
  serial.begin(9600);       // start serial communication @ 115200bps
}

void loop()
{
  if ( serial.available() > 0 )      // if data available read
  {
    val = serial.read();         // read , store in 'val'

    if ( val == 'a' )              // if 'a' received led 2 switched off
    {
      digitalwrite(relay1, high);    // turn off pin 2
    }

    if ( val == 'a' )              // if 'a' received led 2 on
    {
      digitalwrite(relay1, low);  // turn on pin 2
    }

    if ( val == 'b' )              // if 'b' received led 3 switched off
    {
      digitalwrite(relay2, high);    // turn off pin 3
    }

    if ( val == 'b' )              // if 'b' received led 3 on
    {
      digitalwrite(relay2, low);  // turn on pin 3
    } //else (ledpin = 3, low)        //set led pin 3 low state
  }
}

i don't know detect when bluetooth device out of range should not planning reset arduino when happens. treat state of program , call appropriate function take whatever action require.

...r


Arduino Forum > Using Arduino > Project Guidance > how do i make my arduino reset when bluetooth lost signal...


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code