BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Arduino bluetooth 2 wheel dc motor car


#1

I made some code that i wanted to use for my blynk project, the code is supposed to controll a 2 wheel car/rover using 3 buttons (v1, v2, v3 in the code), for the bluetooth module i wanted to use the SH-HC-08 (https://www.amazon.com/gp/product/B01N4P7T0H/ref=ox_sc_act_title_1?smid=AFLYC5O31PGVX&psc=1) i dont know if it would work with blynk, i am also using arduino uno and arduino uno motor shield, i just need someone to make sure i can controll the sh-hc-08 with blynk (is it compatible with the blynk ios app?) and is my code going to be able to function correcetly, when i put it into arduino ide and clicked verafiy it went through but i havent yet tested it in real life.

the code - its my first blynk code so its not very good

#define BLYNK_PRINT Serial


#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>

Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 
Adafruit_DCMotor *LMOTOR1 = AFMS.getMotor(1);
Adafruit_DCMotor *RMOTOR2 = AFMS.getMotor(2);



char auth[] = "e7c17d6a8ae446cab9975d01d35e46af";

SoftwareSerial SerialBLE(10, 11); // RX, TX
uint8_t i;

BLYNK_WRITE(V1)
{
   LMOTOR1->run(FORWARD);
  for (i=0; i<255; i++) {
    LMOTOR1->setSpeed(i);  
    delay(10);
  }
  for (i=255; i!=0; i--) {
    LMOTOR1->setSpeed(i);  
    delay(10);
  }
}
BLYNK_WRITE(V2)
{
  RMOTOR2->run(FORWARD);
  for (i=0; i<255; i++) {
    RMOTOR2->setSpeed(i);  
    delay(10);
  }
  for (i=255; i!=0; i--) {
    RMOTOR2->setSpeed(i);  
    delay(10);
  }
}



BLYNK_WRITE(V3)
{
  
  LMOTOR1->run(BACKWARD);
  for (i=0; i<255; i++) {
    LMOTOR1->setSpeed(i);  
    delay(10);
  }
  for (i=255; i!=0; i--) {
    LMOTOR1->setSpeed(i);  
    delay(10);
  }



  RMOTOR2->run(BACKWARD);
  for (i=0; i<255; i++) {
    RMOTOR2->setSpeed(i);  
    delay(10);
  }
  for (i=255; i!=0; i--) {
    RMOTOR2->setSpeed(i);  
    delay(10);
  }
 
    }




    
void setup()
{
  

  Serial.begin(9600);

  SerialBLE.begin(9600);
  Blynk.begin(SerialBLE, auth);

  Serial.println("Waiting for connections...");

;

}

void loop()
{
  
  Blynk.run();
}

#2

Your posted code is not properly formatted… make it hard to read… thus no one will bother :wink:

I fixed it for you… but read here to see how for the future.

Blynk - FTFC

If it is a BLE module it should work… test it.

Not really what we do here… we help you learn how to use Blynk, not teach programming or act as on call code mechanics.

Test it in real life and see what happens :wink:


#3

you need to add key into your keyboard to write this automaticly :smiley:


#4

Yes!.. a Blynk Button Widget that sends a webhook request to a macro function on my PC… now if only someone would write that code for me :rofl: