Je reviens vers vous pour un autre sujet
J'avance sur mon petit projet de hexa... quadripod. Il fonctionne en autonome mais maintenant je souhaite pouvoir le commander avec mon Iphone via un module BLE HM10.
Sauriez-vous m'orienter vers un site, un tuto, un post ? ou m'expliquer en 2 mots comment (si c'est possible) je peux faire communiquer mon module HM10 avec mon arduino en le branchant sur les RX et TX du arduino ?
Le seul truc qui marche et qui me permet de confirmer que mon IPhone communique avec le Arduino via le HM10 est le code suivant :
/* Hey guys! So the wiring here is really easy. Your bluetooth module
wiring is as follows: Vcc goes to 5v, GND goes to GND, Tx goes to
D2, and RX goes to D3.
*/
#define CUSTOM_SETTINGS
#define INCLUDE_GAMEPAD_MODULE
#include <Dabble.h>
int enR = 3; //These are the pins for our motor driver IC
int inAR = 4;
int inBR = 5;
int enL = 6;
int inAL = 7;
int inBL = 8;
void setup()
{
pinMode(enR, OUTPUT);
pinMode(inAR, OUTPUT);
pinMode(inBR, OUTPUT);
pinMode(enL, OUTPUT);
pinMode(inAL, OUTPUT);
pinMode(inBL, OUTPUT);
Serial.begin(250000); // Set your Serial Monitor is set at 250000
Dabble.begin(9600); // This is the baude rate of the HM-10
}
void loop() {
Dabble.processInput(); // This line is crucial in grabbing our data
if (GamePad.isUpPressed())
{
Serial.println("Forward");
analogWrite(enR, 255);
digitalWrite(inAR, LOW);
digitalWrite(inBR, HIGH);
analogWrite(enL, 255);
digitalWrite(inAL, LOW);
digitalWrite(inBL, HIGH);
}
else if (GamePad.isDownPressed())
{
Serial.println("Backward");
analogWrite(enR, 255);
digitalWrite(inAR, HIGH);
digitalWrite(inBR, LOW);
analogWrite(enL, 255);
digitalWrite(inAL, HIGH);
digitalWrite(inBL, LOW);
}
else if (GamePad.isLeftPressed())
{
Serial.println("Left");
analogWrite(enR, 255);
digitalWrite(inAR, LOW);
digitalWrite(inBR, HIGH);
analogWrite(enL, 255);
digitalWrite(inAL, HIGH);
digitalWrite(inBL, LOW);
}
else if (GamePad.isRightPressed())
{
Serial.println("Right");
analogWrite(enR, 255);
digitalWrite(inAR, HIGH);
digitalWrite(inBR, LOW);
analogWrite(enL, 255);
digitalWrite(inAL, LOW);
digitalWrite(inBL, HIGH);
}
else
{
Serial.println("Stopped");
analogWrite(enR, 0);
digitalWrite(inAR, LOW);
digitalWrite(inBR, LOW);
analogWrite(enL, 0);
digitalWrite(inAL, LOW);
digitalWrite(inBL, LOW);
}
}
Lorsque j'appuie sur les touches "Haut", "Bas", "Droite", "Gauche" du Gamepad sur l'IPhone, je vois bien les valeurs changer dans le Terminal de l'IDE :
Je crains que tu ne puisses pas outrepasser l'usage des pin 2 et 3 pour Dabble, voire leur site. En plus, dans Dabbkle.h il y a:
Pour: Dabble.begin(9600); void begin(long baudRate=115200,int rx=2,int tx=3);