A simple Bluetooth machine on Arduino. Assembling a radio-controlled toy car using Arduino


Arduino machine with Bluetooth control from Android phone is a very simple but interesting project on Arduino UNO using the Motor Shield module. On this page you will find out what components you will need to make a robotic machine on Arduino with your own hands, step by step instructions on assembling an electrical circuit and you can download everything necessary programs for Android and Arduino.

Video. Arduino controlled bluetooth machine

For this project we used a Motor Shield L293D module, two geared wheels, an Arduino UNO board, an HC-05 Bluetooth module and two LEDs for the headlights. Control occurs remotely via a Bluetooth signal from a smartphone or tablet. After assembling the model and installing the programs, you can use the app on your smartphone to turn the car, drive forward and backward, and turn the headlights on and off.

DIY Arduino machine

For this project we will need:

  • Arduino UNO board;
  • Motor Control Shield L293D;
  • Bluetooth module HC-05/06;
  • two motors with gearboxes and wheels;
  • 9V battery (crown);
  • 2 resistors and 2 LEDs;
  • body and wheels from an old car;
  • soldering iron, hot-melt gun, utility knife;
  • wires, solder and electrical tape.
Parts for the robot - cars on Arduino UNO

Arduino machine assembly diagram

If you have all the necessary parts (you can do without LEDs and resistors in the project), then next we will look at how to make an Arduino machine with your own hands. First, you should solder wires to the contacts of the motors and secure them with electrical tape so that the contacts do not come off. The wires must be connected to terminal blocks M1 and M2 on the Motor Shield (the polarity can be changed later).


Power to the Bluetooth module comes from the contacts for the servo drive; we will not need servos in the project. And the power supply is a stabilized voltage of 5 Volts, which suits us. It will be more convenient to solder female connectors to the TX and RX ports, and solder pins (BLS) to the Pin0 and Pin1 ports on the Motor Shield. This way, you can easily disconnect the Bluetooth module from the Arduino when you need to upload a sketch.

The LEDs are controlled from the “Pin2” port; here the wire can be soldered directly to the port. If you are making several machines with Bluetooth that you will control simultaneously, we recommend flashing the HC-05 module. Flashing the module is very simple, and then you will no longer confuse the machines, since each will display its own unique name on Android.

Application and sketch for an Arduino machine

After assembling the circuit, download the following sketch for the machine (do not forget to disconnect the Bluetooth module from the Arduino when downloading) and install the application on your smartphone. All files for the project (AFMotor.h library, sketch for the car and Android application) can be downloaded in one archive using a direct link.

#include // connect the library for the shield AF_DCMotor motor1(1); // connect the motor to terminal block M1 AF_DCMotor motor2(2); // connect the motor to the M2 terminal block int val; // free up memory in the controller void setup() (Serial.begin(9600); pinMode(2, OUTPUT); // Port for LEDs motor1.setSpeed(250); motor1.run(RELEASE); // stop the motor motor2.setSpeed(250); // set the maximum motor speed motor2.run(RELEASE); // stop the motor) void loop () ( if (Serial . available ()) // check if any commands are received( val = Serial .read (); if (val == "f") ( // go forward motor1.run (FORWARD); motor1.setSpeed ​​(250); motor2.run (FORWARD); motor2.setSpeed ​​(250) ; ) if (val == "b") ( // go back motor1.run (BACKWARD); motor1.setSpeed ​​(200); motor2.run (BACKWARD); motor2.setSpeed ​​(200); ) if (val == "s") ( // stop motor1.run(RELEASE); motor2.run(RELEASE); ) if (val == "l") ( // turn left motor1.run(FORWARD); motor1.setSpeed(100); motor2.run(BACKWARD); motor2.setSpeed(250); ) if (val == "r") ( // turn right motor1.run(BACKWARD); motor1.setSpeed(250); motor2.run(FORWARD); motor2.setSpeed(100); ) if (val == "1") ( // turn on the LEDs digitalWrite(2,HIGH); ) if (val == "0") ( // turn off the LEDs digitalWrite(2,LOW); ) ) )

Explanations for the code:

  1. For testing, you can send commands from your computer via USB;
  2. The rotation of the motors when connected to the battery will be different;
  3. You can set your own rotation speed with the motors.

After checking the operation of the machine, install the application on your smartphone or tablet. When you first connect to the Bluetooth module HC-05/06, you will need to pair with Android (then pairing will be performed automatically). If you have difficulty connecting, read this article

But also from the purchase of a ready-made, full-fledged robot based on this board. For children of primary school or preschool age, such ready-made Arduino projects are even preferable, because The “unanimated” board looks a bit boring. This way It is also suitable for those who are not particularly attracted to electrical circuits.

By purchasing a working robot model, i.e. in fact, a ready-made high-tech toy can awaken interest in independently designing and creating robots. Having played enough of such a toy and understood how it works, you can begin to improve the model, take everything apart and start assembling new projects on Arduino, using the freed up board, drives and sensors. The openness of the Arduino platform allows you to make new toys from the same components.

We offer a small overview of ready-made robots on the Arduino board.

Arduino machine controlled via Bluetooth

Car controlled via Bluetooth, costing just under $100. Supplied unassembled. In addition to the case, motor, wheels, lithium battery and charger, we get an Arduino UNO328 board, motor controller, Bluetooth adapter, remote control and more.

Video featuring this and another robot:

A more detailed description of the toy and the opportunity to buy it on the website of the DealExtreme online store.

Arduino Turtle Robot

Robot turtle assembly kit costing about $90. The only thing missing is the shell, everything else necessary for the life of this hero is included: Arduino Uno board, servos, sensors, tracking modules, IR receiver and remote control, battery.

The turtle can be bought on the DealExtreme website, a similar cheaper robot is on Aliexpress.

Arduino tracked vehicle controlled from a cell phone

Tracked vehicle controlled via Bluetooth cell phone , costing $94. In addition to the track base, we get an Arduino Uno board and an expansion board, a Bluetooth board, a battery and a charger.

The tracked vehicle can also be purchased on the DealExtreme website, ibid. detailed description. Maybe a more interesting iron one Arduino tank on Aliexpress.

Arduino car driving through mazes

Car driving through mazes, costing $83. In addition to motors, the Arduino Uno board and other necessary items, it contains tracking modules and obstacle avoidance modules.

Ready-made robot or frame for a robot

In addition to the use case discussed in the review ready-made kits to create Arduino robots, you can buy a separate robot frame (body) - it can be a platform on wheels or a caterpillar, a humanoid, a spider and other models. In this case, you will have to do the stuffing of the robot yourself. An overview of such cases is given in ours.

Where else can you buy ready-made robots?

In the review, we chose the cheapest and most interesting in our opinion ready-made Arduino robots from Chinese online stores. If you don’t have time to wait for a parcel from China - big choice ready-made robots in the online stores Amperka and DESSY. Low prices And fast delivery offers online store ROBstore. List of recommended stores.

You might also be interested in our reviews of Arduino projects:


Arduino training

Don't know where to start learning Arduino? Think about what is closer to you - assembling your own simple models and their gradual complication or familiarization with more complex but ready-made solutions?

Machine on arduino and Bluetooth without code editing. We will use specialized free software to create the sketch. In addition, you don’t need to buy a chassis for our craft; almost any faulty radio-controlled model of a car or tank will do.

I suggest watching an overview video about the Bluetooth-controlled machine and its contents.

So, let's look at a live example of how to make a remote control via bluetooth c with your own hands. android tablet or a smartphone typewriter. The article, oddly enough, is intended for First level knowledge. There is no guide to editing code in the Arduino IDE, and we will only use it to fill in our code. And we will compose the control algorithm in a program called FLProg. Control program from a smartphone - HmiKaskada_free. But first, about the hardware we need.

Machine on arduino and Bluetooth - hardware.

The first thing you need is chassis, that is, a body with wheels and motors, which will drive for the joy of us and those around us. In my case, the case from radio controlled toy in which the power part burned out. The prospect of renovation seemed dull to me, and I wanted something new for my children. That's how this project was born. The body contains two engines that drive the wheels on the sides of the machine, like a tank. All electronic components were sent for spare parts.

To control the electric motors of our future creation we will need H-bridge on L298N chip Link to Ali, I took this one from. The picture is clickable.

H-bridge for arduino

Can control two motors in the voltage range 5 - 35 volts. Supports PWM, that is, you can adjust the engine speed. The board has a stabilized voltage output of 5 volts for powering the Arduino.

The connection diagram is simple and unpretentious:

The next integral part of the electronic filling of our project is bluetooth module HC-06. The most common module for Arduino, so popular that in additional description does not need.

HC-06 bluetooth for arduino

The main element and brain in my case is arduino nano, I won’t even post photos here because everyone knows about it and knows how to work with it. By the way, any Arduino board will do, as long as it fits in the case 😀

Batteries and soldering wires do not require specification. The choice of batteries depends on the operating voltage of the electric motors.

Machine on arduino and Bluetooth - drawing up a sketch.

I repeat - there will be no digging in the code here. We will use popular program FLProg. Download it latest version can be found on the official website. The program's interface is simple and unpretentious, but it has enormous functionality and support for almost all popular modules. I won’t write how to use it because it would take a couple of articles. Let me just say that I have never met a more convenient and available program for making sketches for arduino and its clones. Interface screen:

FLProg interface

The site is full of text and video manuals, I think you’ll figure it out.

My project for a remote-controlled car can be downloaded from Yandex disk via the link shortening service.

Machine on arduino and Bluetooth - control interface on an Android tablet.

By popular demand I wrote detailed instructions on developing a control interface based on HmiKaskada android in the article. The link is clickable.

For devices under android control there is a program HmiKaskada (link to YandexDisk). It was originally developed as an alternative to expensive industrial HMI panels. But inquisitive minds quickly realized that she could control anything. In our case, a typewriter. Supports wireless interfaces Wi-Fi and Bluetooth, in addition, you can connect the device directly via USB.

There are paid and free versions of the program. I have both but I basically made the project in free version to show you and once again make sure it’s absolutely working free versions. The main difference between free and PRO versions This works only via bluetooth.

There is a giant thread on the FLProg forum regarding compatibility with KaScada, and the developer is active and sociable. I don’t see any point in posting a screenshot of the control panel - it’s in the video.

The main source of information is easyelectronics.com

One arduino is not enough here. You will also need:
-power modules for controlling motors and lights
-power supply module
-communication module

Arduino is just brains, and rather frail ones at that.

The question of compatibility of the motor with the Arduino does not make much sense. The fact is that almost no motor can be connected directly to the Arduino, it will burn out.
There will be an intermediary between the arduino and the motor - a power module. Thanks to this, Arduino is virtually compatible with any motor.

Regarding “where to buy” - either online stores or stores electronic components. Search by search in your city. In large cities you can buy everything in one place, but you will overpay 1.5-5 times compared to Ali.

How would I make a typewriter?

As brains high level and the communication module, I would take something from ESP32 or ESP8266. The first one works with bluetooth and wifi. The second one only works with wi-fi.

An Arduino will also work as a peripheral controller. But! I wouldn’t make a garden out of a bunch of circuit boards and wires - most likely, it won’t fit into the body of the machine, and if it does, it will be very scary.

Therefore, I would place all the components of this design on a specially designed printed circuit board, which will then be manufactured by some Resonit according to my order.

1) Depends on your location and allowance for a slight overpayment. You can order everything you need from China if you are willing to wait 14-40 days, which will save a small part of the total amount.
I personally ordered from the following comrades:

Accordingly, no problems arose.
2) For that matter, you need two DC motors and one servo. Just enter "DC motor" and "Servo".
Issue examples:

When choosing a servo, you need to pay attention to the gears and, of course, the thrust being developed. In principle, for a banal toy car, the first option given in the example is enough. But for the future, keep in mind that the “MG” prefix implies metal gears, which makes the device generally more resistant to damage, although it does not eliminate them.
To control this entire system you will also need a so-called "motor shield":

The first example given, thanks to the presence of a shift register and two bridges, allows you to simultaneously control four motors. The only thing that will be a problem is food, because... For adequate functioning, each requires 5V, otherwise there may be problems with the developed power.
In principle, the second one can also control four wheels at once, simply connecting them in pairs (to turn, use the difference in speed of the sides). But in your case, the second option will be sufficient. Moreover, it allows the use of higher currents than the first.
3) Simply purchase LEDs and connect them either directly (not forgetting the resistors) or through one of the microcircuits.
"Diod"

4) Simply install the Arduino IDE and use C/C++

Resources to explore:

p.s. concerning remote access, then pay attention to my friend’s answer above

1) Where to buy the Arduino itself?
Yes
2) What engines will be compatible with this single board? You need a couple of motors to move the machine, and as I understand it, you need a stepper motor to turn the machine.
Any, but you cannot connect any motor directly, you need a special motor control nameplate, for example, this one. For the rotating mechanism, stepper motors are not used, but

What we need:

1. Robot chassis, =$9.50
2. Motor driver, =$1.22
3. A sensor that will detect an obstacle, I settled on the most popular and cheapest option = $0.94
However, no one bothers you to use more expensive ones or something similar
4. Mounting the sensor, not the best, but a viable option. =$1.08
As analogues: there is also the elusive yellow one, which has been searched for the most, but I have not found the link. Who will look for it, it looks like blue, but it has normal holes for an M3 screw and 4 screws for attaching a rangefinder.
5. An arduino board that will process data from the sensor and issue a decision on where to go next. I settled on , as the most convenient for modeling on the fly = $5.88
This board was chosen because of the ability to replace the microcontroller in case of fatal failure, so you can buy a version

In total I spent about $19 on the basics.

!!! terminals, connectors, pliers can be replaced

I will need the above later and more than once, it’s not necessary to accelerate like that

A couple of photos for a snack

Wires and terminals


Stands, bolts, nuts, washers

Assembly

Let's move on to the fun part - the creation of Frankenstein!
First of all, we drill a hole in the blue bracket for the M3 bolt, because I didn’t find any other mounting option


We put the rangefinder on hot glue.


We assemble the chassis and attach our sensor. In order for it to be located as low as possible, we had to not fix it directly to the chassis, but use a stand to lower it a few centimeters down. The bottom edge of the bracket was flush with the motors.

We attach the motor driver and connect the motors.



We adapt a power bank instead of a battery compartment.
To do this, we make two holes for M3 screws for mounting on the chassis, solder two wires “+” and “-” to the USB on the board and bring the wires out through another drilled hole. Unfortunately, I didn’t have a suitable switch on hand, so this function will be performed by disconnecting the wiring from the Arduino. Next, we attach this thing to the chassis.





Install the Arduino and connect the wires




It’s convenient that the battery is charged via a power bank.

We insert the battery, flash it (I used the atmel studio 6 environment), turn it over so it doesn’t run away, and test what happened.

At first glance, everything is fine; if an obstacle appears, the machine turns to the side, checks for the presence of an obstacle, and if it is detected again, turns in the other direction. What happened in practice: it detects obstacles with a bang, turns well, has experimentally set the necessary delays, but is practically unable to drive in a straight line due to the rear steering wheel. Most likely I came across such a “tight” option, but because of this the car always drives diagonally, a trifle, but unpleasant.

Let's sum it up

To begin with, those who decide to do something similar should pay attention to the chassis with four motors. Such a step, in theory, will eliminate the possibility of movement in an arc, but can add headaches when selecting a motor driver. But don’t rush to rack your brains, you can leave this one, everything should work perfectly, the currents pass end-to-end - two motors per channel. But a single-jar power bank is definitely not enough. In my opinion, this is already a reason to take a risk. You will also have to buy washers, because... When attached to plastic, unpleasant things can happen. It would also be great to separate the power supply of the arduino and motors, or use a stabilizer, or at worst solder a capacitor large capacity, but this is for true connoisseurs, it works for me too. In practice, I kept the price to about 2,000 rubles, it could have been cheaper, but this was my exercise for the mind and my first experience in programming (which is what everything was started for), I didn’t save much. When I have time, I’ll attach the radio control and switch.

P.S. The problem of moving in an arc was solved by replacing the motors, thanks for the advice. When purchasing a chassis, do not rush to confirm, first test it in action. There are no more jambs, everything works.







2024 gtavrl.ru.