/*
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?
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?
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
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.
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.