project assistance needed

Hi, Im making a RC boat controlled through an android phone. Im using the Arduino Uno board, a hc-05 bluetooth module, a micro servo and a motor driver. Im having trouble compiling the code, it continues to say; avrdude: stk500_recv(): programmer is not responding

My code is shown below, can someone please help as I have to meet a deadline.

#include <SoftwareSerial.h>
#include <Servo.h>

int bluetoothTX = 2;
int bluetoothRX = 3;

SoftwareSerial bluetooth(bluetoothTX, bluetoothRX) ;

// Motor 1 - controlled forward and back
int Motor1A = 5;
int Motor1B = 6;

// Motor 2 - controlled left and right
int Motor2A = 9;
int Motor2B = 10;

Servo myservo;
int ServoPort = 4;
int ValueLeft = 60;
int ValueMid = 30;
int ValueRight = 0;

void setup ()

{
//Setup Bluetooth serial connection to IOS
bluetooth.begin(115200);
bluetooth.print("444");
delay(100);
bluetooth.println("U,9600,N");
bluetooth.begin(9600);

pinMode( Motor1A, OUTPUT );
pinMode( Motor1B, OUTPUT );
digitalWrite( Motor1A, LOW );
digitalWrite( Motor1B, LOW );

pinMode( Motor2A, OUTPUT );
pinMode( Motor2B, OUTPUT );
digitalWrite( Motor2A, LOW );
digitalWrite( Motor2B, LOW );

myservo.attach(ServoPort);
myservo.write(ValueMid);
}

int flag1 = -1;
int flag2 = -1;

void loop()

{

//Read from bluetooth and write to usb serial
if(bluetooth.available())
{
char toSend = (char)bluetooth .read();
bluetooth.write(toSend);
if(toSend == '5')
{
flag1 = 0;
flag2 = 0;
digitalWrite( Motor1A, LOW );
analogWrite( Motor1B, LOW );

digitalWrite( Motor2A, LOW );
analogWrite( Motor2B, LOW );
}
if ((toSend == 'F') || (toSend == 'G') || (toSend == 'I'))

{
if(flag1 != 1)
{
flag1 = 1;

digitalWrite( Motor1A, HIGH );

analogWrite( Motor1B, 50 );

}

}

if(toSend == 'B' || toSend == 'N' || toSend == 'J')

{

if(flag1 != 2)

{

flag1 = 2;

digitalWrite( Motor1B, HIGH );

analogWrite( Motor1A, 50 );

}

}

if(toSend == 'L' || toSend == 'G' || toSend == 'H')

{

if(flag2 != 1)

{

flag2 = 1;

digitalWrite( Motor2B, HIGH );

analogWrite( Motor2A, 50 );

myservo.write(ValueLeft);

}

}

else

if(toSend == 'R' || toSend == 'I' || toSend == 'J')

{

if(flag2 != 2)

{

flag2 = 2;

digitalWrite( Motor2A, HIGH );

analogWrite( Motor2B, 50 );

myservo.write(ValueRight);

}

}

else

{

if(flag2 != 3)

{

flag2 = 3;

digitalWrite( Motor2A, LOW);

analogWrite( Motor2B, LOW);

myservo.write(ValueMid);

}

}

}

}

Im having trouble compiling the code, it continues to say; avrdude: stk500_recv(): programmer is not responding

Can you compile something simple and download it to your UNO (like BLINK? If not, try a different USB cable. Double-check your ArduinoGUI options. (Tools/Serial Port) Have you checked to see if the UNO is being enumerated to a Com port?

Googling the error you referenced provides these explanations/solutions.

Ray

I have to meet a deadline.

If you read and apply the guidelines in the "how to use the forum" stickies, you are more likely to get help (meaningful title, code tags, full text of error message).

I'm not sure an HC-05 is such a good idea for a rc boat - unless you keep it on a small and shallow pond. It's range is about 10m, so you might easily wander off, and the next landfall is Takoradi Roads. I have strong doubts about using bluetooth at all but, if you must, and you have a BT4 phone, an HM-10 is a rather better choice.

Nick_Pyner:
I'm not sure an HC-05 is such a good idea for a rc boat<...>

I was wondering about that myself but figured reality would come to roost if the boat was in anything bigger than a home swimming pool... or the bathtub! How nerdy would it be to have an RC boat controlled by a water resistant iPhone 6 in your hottub? (Probably be crown-sourced tomorrow!)

Ray

Hi,

Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.. :slight_smile:

TomGeorge:
scrolling window that makes it easier to read.

And while you are at it, getting rid of about 90% of those blank lines wlil make it even easier. All that white space is really quite insulting. (Although I have seen worse)

Nick_Pyner:
I'm not sure an HC-05 is such a good idea for a rc boat - unless you keep it on a small and shallow pond. It's range is about 10m, so you might easily wander off, and the next landfall is Takoradi Roads. I have strong doubts about using bluetooth at all but, if you must, and you have a BT4 phone, an HM-10 is a rather better choice.

Hi Nick_Pyne,

I ever made an RC car using HC-05 bluetooth and it's running quite well in my room so that the distance is not the big matter. But I can only connect to Android phone and not successfully with iPhone.

Is it possible to connect HC-05 to iPhone?

Thanks,

The big difference between a car and a boat is that, if it gets away from you, you might catch the car on your bike.

The HC-05 will not work with iPhone because it is a BT2 device. You need an HM-10, which is BT4. This is essentially a drop-in replacement for the HC-05, it is only about $1 more these days, and the Arduino code is the same. What's more, you get about three times the range, hence my original comment.