Hi,
I am trying to get 3 bi-directional DC motors to work along with a 180 degree servo. 2 of the DC motors will steer and drive the rc car I am building. These 2 are my main concern at the moment. I am using an HM-10 Bluetooth module and a L298N motor shield (although I suspect I will eventually have to switch to an Adafruit v2, but thatās neither here nor there) I have been able to connect to my bluetooth module for some time now and had it controlling my 180 degree servo before I introduced the motorshield into the equation (because servos can just be straight wired to the arduino and donāt require a motor shield.) Now that I am trying to get the motor shield involved Iām getting nowhere. Can someone pleeeeease help me by posting their code to get one dc motor working and controlled via a button on the blynk app. I know I have it wired correctly and I also know I have bluetooth and a servo good to go. But this rc car is useless if I canāt actually drive it! Here is my code that currently runs 2 servos (although I will be using 1 now.)
#define BLYNK_PRINT Serial
#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>
#include <Servo.h>
SoftwareSerial SwSerial(10, 11); // RX, TX
char auth[] = ād651b25ee9394d8fb295690a7317a317ā;
Servo servo1;
Servo servo2;
BLYNK_WRITE(V5)
{
servo1.write(param.asInt());
}
BLYNK_WRITE(V6)
{
servo2.write(param.asInt());
}
SoftwareSerial SerialBLE(10, 11); // RX, TX
void setup()
{
// Debug console
Serial.begin(9600);
SerialBLE.begin(9600);
Blynk.begin(SerialBLE, auth);
Serial.println(āWaiting for connectionsā¦ā);
servo1.attach(5);
servo2.attach(6);
}
void loop()
{
Blynk.run();
}
//end code