However i am getting the error code, expected unqualified-id before numeric constant, on line two. has any one got any ideas on how this can be solved?

#include <SoftwareSerial.h>
SoftwareSerial BlueTooth(5, 6); // (TXD, RXD) of HC-06
char BT_input; // to store input character received via BT.
int motorPin1 = 8; // pin 2 on L293D IC
int motorPin2 = 9; // pin 7 on L293D IC
int motorPin3 = 10; // pin 15 on L293D IC
int motorPin4 = 11; // pin 10 on L293D IC *error is here *

void setup()
{
BlueTooth.begin(9600);
Serial.begin(9600);
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
}

void loop()
{
if (BlueTooth.available())
{
BT_input=BlueTooth.read();
if (BT_input=='s')
{
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
Serial.println("Motors are Off");
}
else if (BT_input=='b')
{
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
Serial.println("Motors are rotating left");
}
else if (BT_input=='f')
{
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
Serial.println("Motors are rotating right");
}
else if (BT_input=='r')
{
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
Serial.println("First Motor is rotating right & Second is left");
}
else if (BT_input=='l')
{
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
Serial.println("First Motor is rotating Left & second is right");
}
}

}

Please reply me

The easier you make it to read and copy the code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

How can I solve this problem?

The code compiles OK for me

IDE 1.8.13
Board Nano
Windows 10

Please use the Copy Error messages button in the IDE and post the full error message here

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

A picture of code is a waste of time

Did you read the advice in the link I provided ? If so then you ignored it

Still no code tags

What is so hard about

  • Paste your code in the box where you are editing your post, select all the code and click on </>.

or

  • In the Arduino IDE under the 'Edit' menu there is 'Copy for Forum', this puts your code on the clipboard with code tags added ready to paste into your question.

Hello sir/ma'am
I just edited given as per your instructions

#include <SoftwareSerial.h>
SoftwareSerial BlueTooth(5, 6); // (TXD, RXD) of HC-06
char BT_input; // to store input character received via BT.
int motorPin1 = 8; // pin 2 on L293D IC
int motorPin2 = 9; // pin 7 on L293D IC
int motorPin3 = 10; // pin 15 on L293D IC
int motorPin4 = 11; // pin 10 on L293D IC      *Error is here and compiled is done for me but whenever I upload the code on Arduino it's not work. 

void setup()  
{
  BlueTooth.begin(9600);  
  Serial.begin(9600);
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);
}

void loop() 
{
  if (BlueTooth.available())
  {
   BT_input=BlueTooth.read();
    if (BT_input=='s')
    {
      digitalWrite(motorPin1, LOW);   
      digitalWrite(motorPin2, LOW);   
      digitalWrite(motorPin3, LOW);   
      digitalWrite(motorPin4, LOW);   
      Serial.println("Motors are Off");
    }
    else if (BT_input=='b')
    {
      digitalWrite(motorPin1, LOW);   
      digitalWrite(motorPin2, HIGH);  
      digitalWrite(motorPin3, LOW);   
      digitalWrite(motorPin4, HIGH);  
      Serial.println("Motors are rotating left");
    }
    else if (BT_input=='f')
    {
      digitalWrite(motorPin1, HIGH); 
      digitalWrite(motorPin2, LOW); 
      digitalWrite(motorPin3, HIGH); 
      digitalWrite(motorPin4, LOW); 
      Serial.println("Motors are rotating right");
    }
   else if (BT_input=='r')
    {
      digitalWrite(motorPin1, HIGH); 
      digitalWrite(motorPin2, LOW); 
      digitalWrite(motorPin3, LOW); 
      digitalWrite(motorPin4, HIGH); 
      Serial.println("First Motor is rotating right & Second is left");
    }
    else if (BT_input=='l')
    {
      digitalWrite(motorPin1, LOW); 
      digitalWrite(motorPin2, HIGH); 
      digitalWrite(motorPin3, HIGH); 
      digitalWrite(motorPin4, LOW); 
      Serial.println("First Motor is rotating Left & second is right");
    }
  }
 
}


Error : expected unqualified-id before numerical constant

That code does not produce errors,
the code shown in your screenshot does.

So to solve your problem, use the posted code, not the other one.

Ok sir ,
But in my arduino I given input pins are different and this code is different input pins are used .

That is problem?

That depends on the pins that you are using and the type of board. Which board are you using ?

Are you using the code that you posted ? If not, then please post it and the full error message

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

I used the board is Arduino nano. And can I use d13 pin for Rx or TX pin of Bluetooth hc-05 module?

I given d13 pin in Rx or TX So, could an error occurs?

As @Whandall says, the code you posted compiles OK for him (and me). Is it the code that you are trying to compile ?

Yes, This code are same but I given in arduino input pins are different over code .

Sorry, I am still not getting it

If you are using different pins than the code then it is never going to work, but it should not error when compiled

So, have you posted the actual code that you are using, and if so in which reply, and which pins are you actually using for SoftwareSerial ?

Yes,I have posted the actual code .

And as per the code in used SoftwareSerial pins are 5,6 ad i used the softwareserial pins are 12,13.

Is it the code in post #10 ?

The code in post #10 uses pins 5 and 6 for SoftwareSerial

SoftwareSerial BlueTooth(5, 6); // (TXD, RXD) of HC-06

In post #17 you say that you are using different pins

So, which pins are you using ?

1 Like

i used the softwareserial pins are 12,8

Can I used this pin?