Please Help – Arduino BT Car

Hey guys I need your help. After years I decided to start a project with my arduino. I thought it would be funny to make an BT controlled car..

I am using following components. – Arduino Uno Rev 3 – KA03 Motorshield (L298P) – HM-10 bluetooth module (used hc-05, but its not able to connect to an iPhone) – 2 Resistors (1k and 2.2k [divider RX-GND]) -Dabble (BT controll app)

I managed to connect the App with the module (at least it seems so)

Now I will describe the issue: If I press the buttons nothing happens. I checked the serialmonitor, but I only receive „stop“ and nothing else.

I already read, that it should stop if I type in „AT“ but nothing happens.

Maybe you can help me, or check my code. BR, Carlos

/*

Code by Pascal

BT hm-10 RX –> 2 TX –> 3

*/

define CUSTOM_SETTINGS

define INCLUDE_GAMEPAD_MODULE

include <Dabble.h>

//setup pins int motorA_en = 5; int motorB_en = 9; int motorA_dirF = 4; int motorA_dirB = 7; int motorB_dirF = 12; int motorB_dirB = 13;

void setup() {

Serial.begin(250000); //Serial.begin(9600); Dabble.begin(9600); //Dabble.begin(38400); //set pins as output pinMode(motorA_en, OUTPUT); pinMode(motorB_en, OUTPUT); pinMode(motorA_dirF, OUTPUT); pinMode(motorA_dirB, OUTPUT); pinMode(motorB_dirF, OUTPUT); pinMode(motorB_dirB, OUTPUT);

}

void loop() {

Dabble.processInput();

if (GamePad.isUpPressed())

{ Serial.print("UP"); forward(); }

else if (GamePad.isDownPressed()) { Serial.print("DOWN"); backward(); }

else if (GamePad.isLeftPressed()) { Serial.print("Left"); left(); }

else if (GamePad.isRightPressed()) { Serial.print("Right"); right(); }

else { Serial.println("stop"); Stop(); }

}

void forward() { analogWrite(motorA_en, 255); analogWrite(motorB_en, 255); digitalWrite(motorA_dirF, HIGH); digitalWrite(motorA_dirB, LOW); digitalWrite(motorB_dirF, HIGH); digitalWrite(motorB_dirB, LOW); } void backward() { analogWrite(motorA_en, 255); analogWrite(motorB_en, 255); digitalWrite(motorA_dirF, LOW); digitalWrite(motorA_dirB, HIGH); digitalWrite(motorB_dirF, LOW); digitalWrite(motorB_dirB, HIGH); } void left() { analogWrite(motorA_en, 255); analogWrite(motorB_en, 255); digitalWrite(motorA_dirF, LOW); digitalWrite(motorA_dirB, HIGH); digitalWrite(motorB_dirF, HIGH); digitalWrite(motorB_dirB, LOW); } void right() { analogWrite(motorA_en, 255); analogWrite(motorB_en, 255); digitalWrite(motorA_dirF, HIGH); digitalWrite(motorA_dirB, LOW); digitalWrite(motorB_dirF, LOW); digitalWrite(motorB_dirB, HIGH); } void Stop() { analogWrite(motorA_en, 0); analogWrite(motorB_en, 0); digitalWrite(motorA_dirF, LOW); digitalWrite(motorA_dirB, LOW); digitalWrite(motorB_dirF, LOW); digitalWrite(motorB_dirB, LOW); }

Touch here for the full post on the Arduino Apprentices tumblr

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s