german version see below
Hey, I started a little project with my Arduino Uno but now I reached the end of my knowlegde and need help.
I use:
-Arduino Uno R3
-KA03 Motorshield (L298P)
-hm-10 BT module (used hc-05 but was not connectable with my iPhone)
-resistors (1k and 2.2k at the RX pin)
-dabble (App)
I can find and connect the module with the phone via the app.
If I press now the buttons of the app, nothing happens. I checked the serialmonitor, but it only writes "stop". So maybe the module receives nothing.
I also downloaded the manufactor`s app and connected with it, but it shows "wrong password"?
In the serialmonitor I tried to send "AT" but nothing happened.
Maybe there is a issue in my code.. Thank you for your help!
german:
Hallo, wollte meinen angestaubten Arduino für ein BT-Car nutzen, doch es funktioniert nicht wie gewollt. Ich nutze die "dabble" App und die Verbindung zum hm-10 scheint zu funktionieren, jedoch passiert nichts, wenn ich die Buttons drücke. Im serialmonitor wird immer nur "stop" geschrieben, also scheint kein anderer Befehl befolgt zu werden.
Habe auch die BT-App des Herstellers versucht und die Verbindung wird hergestellt (LED am Modul leuchtet, statt zu blinken), aber es wird "wrong password" angezeigt. Am Telefon wird das Modul nach Verbindung mit der App unter den BT-Geräten als verbunden angezeigt, davor ist es nicht sichtbar. Vielleicht liegt der Fehler aber auch im Code..
Jedenfalls, danke im Voraus.
/*
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);
Dabble.begin(9600);
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);
}