Arduino board type used in this session is Arduino Uno R3 DIP/SMD CH340

Below is the description of wiring and code in Arduino to assemble a Bluetooth RC car using android smartphone:

  1. Tested the motor dc result both of wheel works (can spin forward and or backward). power direct from the battery.
  2. Tested HC-05 bluetooth moduled. The phone can paired the bluetooth module.
  3. Tested out1 out2 out3 and out4 on L298N using direct power from the battery the wheel spinning (forward and or backward).
  4. The code for the Bluetooth rc simple car used below as described.

The car failed to move (forward, backward, turn left/right). how to make the motor dc and or the motor stepper works remotely. thank you

Wiring Table

L298N Motor Stepper / Driver Motor

HC-05 Bluetooth module

Pin to Arduino

Fritzing Skematic #include SoftwareSerial mySerial(12, 13); // RX, TX #define m1 3 #define m2 5 #define m3 9 #define m4 10

int data=0,kec=0;
boolean forward=true;

int fast[11]={0,80,100,120,140,160,180,200,220,240,255};

void setup()


void motorOut(unsigned char lpwm, unsigned char rpwm, boolean arrow){

void loop(){
    if (data =='0') { kec=0;}
      else if (data =='1') { kec=1;}
        else if (data =='2') { kec=2;}
          else if (data =='3') { kec=3;}
            else if (data =='4') { kec=4;}
             else if (data =='5') { kec=5;}
              else if (data =='6') { kec=6;}
                else if (data =='7') { kec=7;}
                  else if (data =='8') { kec=8;}
                    else if (data =='9') { kec=9;}
                      else if (data =='q') {kec=10;}

  //S= Stop
 if (data == 'S')
 { motorOut(0,0,false); }

if (data=='F')
{ motorOut(fast[kec],fast[kec],true); }

//I=turn right forward
if (data=='I')
{ motorOut(fast[kec],((fast[kec])/2),true);}

//G=turn left forward
if (data=='G')
{ motorOut(((fast[kec])/2),fast[kec],true); }

//R=turn right
{ motorOut(fast[kec],0,true); }

//L=turn left
{ motorOut(0,fast[kec],true); }

{ motorOut(fast[kec],fast[kec],false); }

//H=turn left back
 if (data=='H')
   { motorOut(((fast[kec])/2),fast[kec],false); }

//turn right back
   if (data=='J')
    { motorOut(fast[kec],((fast[kec])/2),false); }
  • 1
    you forgot to ask a question
    – jsotola
    Commented Jul 9, 2018 at 3:34
  • 1
    what tests have you done?
    – jsotola
    Commented Jul 9, 2018 at 3:35
  • Instead of writing many if-else if statements, use a simple switch(data){ case '0':
    – chrisl
    Commented Jul 9, 2018 at 13:17
  • What data gets send to mySerial? Can you confirm, that the correct data is actually received? Maybe echo it back to the source. If this doesn't work, your serial connection doesn't work (maybe because the HC-05 isn't really connected). If it works, try to drive the motor through the driver, by connecting the corresponding pins to 5V. If this doesn't work, your driver connection is not correct. You should provide a schematic instead of photos.
    – chrisl
    Commented Jul 9, 2018 at 13:26
  • nothing displayed data from serial monitor. HC-05, icon indicator green in android phone (success conecting to the car). L298N, the motor run after i give direct power to PIN 5 and Ground. the battery 4 x 1.2 alkaline or 9v
    – user47938
    Commented Jul 12, 2018 at 19:49

1 Answer 1


sorry for my careless. finaly its works....wrong pin assign the main problem....should be IN1, IN2, IN4 and IN3 not IN1, IN2, IN3 and IN4. thank you for all hands for help before

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.