Code bluetooth module

In every tutorial i watch they say 'just copy the code' without explaining how it works can someone help me?
Also does someone know a good app to control an rc car with the bluetooth module? Thx

Welcome to the forum

Please post a sketch that you want an explanation of

You should post a link to the video that you watched.
Otherwise the explanation stays very general:

mark the code
press ctrl-c for copying the code into the clipboard
change to arduino-IDE press ctrl-V to paste the code into the IDE-exteditor

If you have more questions you will have to ask much more specific than
"how works copying code"

This app has to play very well together with the code on your arduino.
So there is not a this one single solution.

If a app is "good" or not depends on your arduino-code

the video is "https://www.youtube.com/watch?v=sXs7S048eIo&t=2s"
couldn't find a download for the code though

Below the video is a hidden link "more.."
in german "mehr..."

If you click on this "more..."
you see a link


This link leads to the youtubers website.
Though if the link does not work

you can do an advanced google-search
https://www.google.com/advanced_search

where you narrow the google-search to this website
https://www.google.com/search?as_q=bluetooth+arduino&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=https%3A%2F%2Fwww.tinkernut.com%2F&as_occt=any&as_filetype=&tbs=
which will lead you to the correct sub-website of tinkernut

with keywords Arduino blu

Here is s commented sketch

#include <SoftwareSerial.h>  
SoftwareSerial BT(2, 4);    //pin 2 is Rx, pin 4 is Tx
// creates a "virtual" serial port/UART
// connect BT module TX to D10
// connect BT module RX to D11
// connect BT Vcc to 5V, GND to GND
void setup()
{
    // set digital pin to control as an output
    pinMode(13, OUTPUT);
    // set the data rate for the SoftwareSerial port
    BT.begin(9600);
    // Send test message to other device
    BT.println("Hello from Arduino");
}
char a;  // stores incoming character from other device
void loop()
{
    if (BT.available())
    // if text arrived in from BT serial...
    {
        a = (BT.read());
        if (a == '1')
        {
            digitalWrite(13, HIGH);
            BT.println("LED on");
        }
        if (a == '2')
        {
            digitalWrite(13, LOW);
            BT.println("LED off");
        }
        if (a == '?')
        {
            BT.println("Send '1' to turn LED on");
            BT.println("Send '2' to turn LED on");
        }
        // you can add more "if" statements with other characters to add more commands
    }
}

I use the Android Serial Bluetooth Terminal to communicate with the Arduino

1 Like

So basically, you use softwareserial, declare it as bt and then send any data that would normally go through serial through 'BT'?

Also, what would the pin connections look like in this instance?

Martyn Currey's Bluetooth tutorials are excellent.

I was hoping that the comment in the code would make it obvious

SoftwareSerial BT(2, 4);    //pin 2 is Rx, pin 4 is Tx

As usual, Tx on the GPS goes to Rx on the Arduino and vice versa

That depends on what you regard as normal. For any AVR based Arduinos such as the classic Unos and Nanos it is not normal to use pins 0 and 1 for anything unless you really know what you are doing

Correct. "Serial" is serial with wires while "BT" is serial without wires. The commands are essentially the same, and the formatting is exactly the same.

Note also that, particularly if you are not using the keyboard, there is no obligation to use software serial. An example of this is in the link in your reply#4.

That guy types out his code on the screen. There is nothing to suggest it isn't kosher.

But note though, that it is good practice to have a 1k/2k voltage divider in the Arduino Tx line in order to present 3.3v at the Bluetooth Rx pin.

Fritz

Don't panic if you have not already done this......

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.