I am getting this error though the programming is right

When you use software serial did you look at the examples on how to use software serial?

Arduino - SoftwareSerial

An example of software serial use:


/*
  Software serial multple serial test

 Receives from the hardware serial, sends to software serial.
 Receives from software serial, sends to hardware serial.

 The circuit:
 * RX is digital pin 2 (connect to TX of other device)
 * TX is digital pin 3 (connect to RX of other device)

 Note:
 Not all pins on the Mega and Mega 2560 support change interrupts,
 so only the following can be used for RX:
 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

 Not all pins on the Leonardo support change interrupts,
 so only the following can be used for RX:
 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

 created back in the mists of time
 modified 25 May 2012
 by Tom Igoe
 based on Mikal Hart's example

 This example code is in the public domain.

 */
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Native USB only
  }


  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(38400);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}


Does your attempt to use software serial look like it was ever setup to properly function?

I'l tell you in 10 minutes

You have hardware and software issues.

Have you been correcting the hardware issues? If so could you post an update so we can get an idea of the new what not thing do.

And post your latest attempt at using software serial on the Uno.

If you do not correct the hardware issues as has been pointed out, then the software issues will NOT go away.

Here is the Physical layout:



Here is the physical layout:



Do you understand that you CANNOT use hardware serial on an Uno to accomplish what you want to do?

Do you understand that you must use, to accomplish what you want to do with the hardware you currently possess, softwareserial and you cannot use pins 0 and 1 for softwareserial?

What pins should I use for software serial

If you do not want to do this on your own, I'll post step by step instructions for you.

Step one, remove the connections from pin0 and pin1, post a new picture to prove you followed those instructions.

Then you will get step 2.

Ok thanks but I have to sleep cause it's night here.
So i'l do it in 11 hours

But pls reply then

What? This is unusual. Sleep after you get this working…

a7

as a general advice:
You should connect only one single device separately and test if the device is working as expected.

If it does work. Disconnect this device
and connect the next device separately and test this device.

In your case test the motordriver separately
then test the bluetooth module separately.

If you put all things together immediately there are much more possabilities for errors and that wrong connected things can influence each other.

Of course you are learning. And one thing to learn is:
Testing things separately is a time-saver though it needs extra time to test it separately.

This has a second advantage: learning to code with functions.
Each thing that a program does and that builds a senseful unit should be its own function.

So possible functions could be

  • driveForwards

  • driveBackwards

  • driveLeft

  • driveRight

  • receiveBluetoothCommand

  • set motorspeed

etc.
through dividing your code in such functional units the code becomes very easy to modify and to maintain. Again a time-saver which looks like needing more time in the beginning.

Here is a tutorial that explains how to use the L298N-motor-shield

best regards Stefan

The picture you have taken do not say very much.
Again: trying to be quick in fact slows you down.

On the bluetooth-module picture the wirecolors are not visible
Only if you take pictures from vertical above it will be easy to see which wire is connected to what or exact in front. Pictures showing important surfaces in other angles than 90degrees are hard to "read"

There should be a picture that shows all parts at once. But in most cases then the resolution is too small.

This is the reason why it makes sense to draw a schematic by hand
that only shows those pins that are connected to each other.

As schematic like this is totally sufficient: it names the connected pins and the devices and leaves out unrelevant information

I have chosen these IO-pins for the following reasons:

keep IO-pin 2 and 3 free for eventual future use for interrupts. (only IO-pins 2 and 3 are usable for interrupts. This means connect the Bluetooth-modul to IO-pin 4 and 5

Use IO-pin 10 and 11 for motorspeed-control because io-pin 10 and 11 are PWM-capable.

best regards Stefan

Nah. You always see the problem instantly after a night's sleep. :slight_smile:

Ok thanks Stefan super helpful I will follow your advise for the success of my future projects.

Hello I have slept and here is the image


Hello, I tried making a schematic here it is. I know it is the worst but do you mind checking?


Schematic still shows the HC05 connected to hardware serial. And motor driver 5V connected to Vin.

My solutions wake me at 4AM and I can't go back to sleep until I try them.