Android Bluetooth joystick

janzluc14
Have a look at your digitalRead logic questions and answers received ... or not ... http://arduino.cc/en/Tutorial/DigitalReadSerial see if you can sort it out.

I'd also suggest that you only need to find the ON / HIGH state... so... IF it's HIGH find route ELSE forward.

void motorwiper()
  {
  
    dist = digitalRead(switchPin);    //read the switch
  
    if(dist != object)
    {                         //if distance is not equal to object
      forward();               //then move forward
    }
    if(dist == object)
    {               //if distance is equal to object
      findroute();
    }
  
  }