First project - bluetooth bot

This is my first arduino project and I am completely uninitiated in C++.

I have cobbled together a functioning robot control out of example sketches for; bluetooth light switch, servo sweep, L293D digital pin dual motor control.

It functions adequately as a concept but there are still a few hurdles to overcome.

Firstly, when the bluetooth input is received it turns confirmation on with Digitalwrite(#,HIGH) until another signal is received. I want RC car style input where the second u stop pressing the button the output stops.

I have tried the operator else if(inputString != "x")
this kills all other inputs like else if(inputString == "y")
and it still requires a new input to overwrite "x"

is there a (inputString == "nothing") operator to identify no signal?

I could get around this by sending end signals from the controller when the button stops being pressed. Is there a bluetooth app for android that will send a second signal when the button stops being pressed? I have noticed that the "arduino bluetooth controller" app only sends the signal when the button is released. This wont work for what i want, could anyone recommend a robust app that can send signal on button press as well as button release?

Secondly, I want to be able to write delays into servo functions without putting a delay in the void loop when used. This is so u can make a servo do something and then still receive inputs for other functions.

I have no idea how i would even approach this.

Thirdly, I want to move the servos left or right based on continuous input signal and write(pos) at the position the servo loses the direction input signal. I'm pretty sure I can already do this but I can't try it until i overcome the first hurdle as stated above.

My sketch to control an LED, 2 motors, and 2 servos.

#include <Servo.h>

Servo myservo1;
Servo myservo2;// create servo object to control a servo

int m1 = 3; // motor1, 1
int m2 = 6; // motor2, 1
int en1 = 4; // motor1, 2
int en2 = 7; // motor2, 2
int pos = 0; // variable to store the servo position
char junk;
String inputString="";

void setup() // run once, when the sketch starts
{
Serial.begin(9600); // set the baud rate to 9600, same should be of your Serial Monitor
pinMode(13, OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
myservo1.attach(9); // attaches the servo on pin 9 to the servo object
myservo2.attach(8);
}

void loop()
{
if(Serial.available()){
while(Serial.available())
{
char inChar = (char)Serial.read(); //read the input
inputString += inChar; //make a string of the characters coming on serial
}
Serial.println(inputString);
while (Serial.available() > 0)
{ junk = Serial.read() ; } // clear the serial buffer
if(inputString == "a"){ //in case of 'a' turn the LED on
digitalWrite(13, HIGH);
}else if(inputString == "b"){ //incase of 'b' turn the LED off
digitalWrite(13, LOW);
}else if(inputString == "c"){
for (pos = 0; pos <= 160; pos += 2) { // goes to 180 degrees
myservo1.write(pos); // tell servo to go to position in variable 'pos'
}
}else if(inputString == "d"){
for (pos = 180; pos >= 10; pos -= 2) { // goes to 0 degrees
myservo1.write(pos); // tell servo to go to position in variable 'pos'
}
}else if(inputString == "e"){
for (pos = 85; pos >= 85; pos -= 2) { // goes to 90 degrees
myservo1.write(pos); // tell servo to go to position in variable 'pos'
}
}else if(inputString == "f"){ //incase of 'f' turn on both motors
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
}else if(inputString == "g"){ //incase of 'g' turn on right motor
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}else if(inputString == "h"){ //incase of 'h' turn on left motor
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
}else if(inputString == "i"){ //incase of 'i' stop both motors
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}else if(inputString == "j"){ //incase of 'j' sweep servo 2 back and forth
for (pos = 0; pos <= 160; pos += 2)
myservo2.write(pos); // tell servo to go to position in variable 'pos'
delay (1000);
for (pos = 160; pos >= 0; pos -= 2)
myservo2.write(pos); // tell servo to go to position in variable 'pos'
}

inputString = "";
}
}

Easy, just send a command when the button changes "state" from pressed to un-pressed.

As for the delay, google "blink without delay." There is a tutorial that explains how to do what you describe by using millis() in a creative way.

Power_Broker:
Easy, just send a command when the button changes "state" from pressed to un-pressed.

What apps can do this for me? "Arduino bluetooth controller" will only send a command when you take your finger off the screen, not when u place the finger on the screen originally. this is good to avoid double pressing in some circumstances.

All i really want is a bluetooth app that can send a signal when touching a specific button on a a phone screen and a different signal when not touching that button. or an app that will send a base signal when no buttons are pressed.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

And the demo Several Things at a Time is an extended example of BWoD

All i really want is a bluetooth app that can send a signal when touching a specific button on a a phone screen and a different signal when not touching that button

This is not a practical proposition - too much data will be sent. What you need to do is send a character when the button is first touched (perhaps send 'B') and send a different character when the button is released (perhpas send 'b').

Alternatively if the phone app only allows you to send a character when the button is released you could send a 'B' and the Arduino would be programmed to turn something on when the first 'B' is received and turn it off when the next 'B' is received.

...R

I found a perfect app

'BlueTooth Serial Controller' has 25 buttons and a Stop Command specific to each button. Perfect for any application.

For the benefit of others can you post a link to the program you refer to?

You may also be interested in this RemoteXY Thread or this alternative

...R