Robots on arduino uno. DIY Arduino robot. Checking the polarity and correct connection of the modules

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

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 body, motor, wheels, lithium battery and charger, we get an Arduino UNO328 board, motor controller, Bluetooth adapter, remote control remote control And so on.

Video featuring this and another robot:

More detailed description toys and the opportunity to buy on the DealExtreme online store website.

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 from a 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, there is also a detailed description there. 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 option of using ready-made kits for creating Arduino robots discussed in the review, you can buy a separate frame (body) of the robot - 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 selected 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 package from China, there is a large selection of ready-made robots in the Amperka and DESSY online stores. Low prices and fast delivery is offered by the 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?

A little about the robot. First of all, the project had to be as inexpensive as possible. The body was created without any calculations or balancing; the main requirement for the body was minimum dimensions. So let's start assembling this robot.

Parts List:
1. A set of body parts and paws made of 1.5 mm plexiglass.
2. Arduino Mega or Uno (Mega is used) - 1 pc.
3. Micro servo drive (TowerPro SG90 is used) - 8 pcs.
4. Ultrasonic rangefinder HC-SR04 - 1 pc.
5. Battery size 18560, 3.7V (TrustFire 2400 mAh is used) - 2 pcs.
6. Battery holder size 18560 (using a converted container - packaging) - 1 pc.
7. Stand for printed circuit board 25 mm. (such stands are used) - 4 pcs.
8. Part breadboard.
9. Jumper wires.
10. Screw DIN 7985 M2, 8 mm. - 18 pcs.
11. Nut DIN 934 M2 - 18 pcs.

Assembly of the Z-RoboDog robot:

1. The robot body is made of transparent plexiglass with a thickness of 1.5 mm. All parts are laser cut according to a drawing made in CorelDraw:

2. Glue the body with second glue. The strength of the glued body will be quite sufficient. When assembling, take into account the position of the holes on the bottom cover (look at the photo), or better yet, attach the board and make sure that everything matches. Attach the side walls so that the holes for the wires are closer to the back wall. The wider hole on the back wall is for a USB cable, keep this in mind when assembling.


3. Mark and drill holes (2 mm drill bit). Secure the servos to the housing using bolts and nuts (items 10, 11 from the list). The front servo shafts should be closer to the front wall. The rear servo drive shafts are closer to the rear wall.




4.1. Collect the paws. Take the top parts of the paws (with two holes). Mark the middle of the part. Having placed the servo drive rocker, mark the mounting points with screws and drill holes (1.5 mm drill). Fasten the rockers so that the screw heads are on the side of the seats. Fix the rockers on different sides and the seats for the shafts were in the opposite direction.


4.2. Mark and drill holes for mounting the servos (2mm drill bit). The shafts of the attached servos should be closer to the narrow edge of the paw.


4.3. To prevent the paws from slipping, stick rubber on them, for example. But you shouldn’t glue the front part of the paw; when the dog steps, it can get caught and get stuck. I glued on strips of sticky mat from the car.

5. Mark and drill holes for attaching the ultrasonic rangefinder (2 mm drill). Install the rangefinder with the contact legs pointing upward.

6. Install the battery holder so that it is located in the middle of the case. Secure the Arduino board and connect all components. A part of the breadboard was used for power distribution.

Setting up and launching the Z-RoboDog robot:

At this point you will have to install the feet yourself so that the steps can be calibrated. The main problem is in the rockers, which are attached to the shafts only in certain positions. And also the servos themselves may differ in operating degrees.

This is what my dog's paws look like at the extreme points of the servo angles (variables zs1, zs2, zs3, etc.). Try to position your paws as in the photo. Visually, the paws should be in the same positions.

In the main stance, you can also put your paws out. Then do not forget to screw the rockers to the servo shafts.


Software part of Z-RoboDog:

The code is very simple, comments are added everywhere. All movements are in an array, so as not to get confused in the numbers, I used variables for each servo. For example, s1 is servo 1, s2 is servo 2 and so on. To make it easier to understand, I offer you this diagram.

The paws are numbered in the diagram; each part of the paw is associated with a servo drive that moves it. Also, for each paw, the directions of movement are indicated; the plus and minus signs indicate where the paw will move when the angle increases or decreases. The starting angles were the corners of the main post (s1, s2, s3, etc.). For example, if you need to extend the 2nd paw, you must increase the angle s3 and s4, in the array it will look like this (s1, s2, s3+100, s4+50, s5, s6, s7, s8). Here's the full sketch. The code was written based on my knowledge, please let me know if I chose the wrong implementation path.

Video:


Sketch in the archive: You do not have access to download files from our server

The result is a rather funny robot that can see obstacles in front of it, analyze the situation and then, only having chosen the best route, moves on. The robot turned out to be very maneuverable. It is capable of turning 180 degrees, and the rotation angle is 45 and 90 degrees. The author used Iteaduino, which is an analogue of Arduino, as the main controller.

Materials and tools for making a robot:
- microcontroller (Arduino or similar Iteaduino);
- ultrasonic sensor;
- battery holder;
- Chinese toys for creating a wheelbase (you can buy a ready-made one);
- wire cutters;
- glue;
- wires;
- motors;
- fiberboard;
- jigsaw;
- transistors (D882 P).

Robot manufacturing process:

Step one. Creating a wheelbase
In order to create a wheelbase, the author bought two Chinese toy cars. However, you don’t have to worry about this if you have extra money, since you can buy a ready-made base. Using wire cutters, the cars were cut in two to create two drive axles. These parts were then glued together. However, in this case you can also use a soldering iron; the plastic can be soldered perfectly.

When choosing cars, it is best to take toys with regular wheels, since, according to the author, with spikes like his, the robot jumps a lot.

There is another moment when wires will come out from the motors; on one of them you need to remember to change the polarity.


Step two. Making the top cover
The top cover of the robot is made of fiberboard; thick cardboard can also be used for these purposes. You can see a rectangular hole in the cover; it should be located so that the axis of the servo drive, which will be inserted into it, is located symmetrically. As for the hole in the middle, the wires will come out through it.


Step three. Robot stuffing
It is best to use a separate power supply to connect the chassis, since the controller requires 9V to power it, while the motors only need 3V. In general, battery holders are already built into the chassis of such machines; they just need to be connected in parallel.








The motors are connected to the controller using D882 P type transistors. They were pulled out from the old machine control panel. It is best, of course, to use power transistors of the TIP120B type, but the author simply chose them based on suitable characteristics. All electronic parts are connected according to the specified diagram.

After flashing the robot's firmware, it will be ready for testing. In order for the robot to have time to turn at a certain angle, you need to choose the right operating time for the motors.

As for sensors, the ultrasonic one needs to be connected to the 7th digital output of the microcontroller. The servo motor is connected to the 3rd digital input, the base of the transistor of the left motor is connected to pin 11, and the base of the right one is connected to the 10th.

If Krona is used as power supply, then the minus is connected to GND, and the plus to VIN. You also need to connect the emitter of the transistor and the negative contact from the robot chassis power supply to GND.

Let's talk about how you can use Arduino to create a robot that balances like a Segway.

Segway from English. Segway is a two-wheeled standing vehicle equipped with an electric drive. They are also called hoverboards or electric scooters.

Have you ever wondered how a Segway works? In this tutorial we will try to show you how to make an Arduino robot that balances itself just like a Segway.

To balance the robot, the motors must resist the robot falling. This action requires feedback and corrective elements. Feedback element - which provides both acceleration and rotation in all three axes (). Arduino uses this to know the current orientation of the robot. The corrective element is the combination of engine and wheel.

The end result should be something like this:

Robot diagram

L298N Motor Driver Module:

Gear motor direct current with wheel:

A self-balancing robot is essentially an inverted pendulum. It may be better balanced if the center of mass is higher relative to the wheel axles. A higher center of mass means a higher moment of inertia of the mass, which corresponds to a lower angular acceleration (slower fall). That's why we put the battery pack on top. However, the height of the robot was chosen based on the availability of materials :)

The completed version of the self-balancing robot can be seen in the figure above. At the top there are six Ni-Cd batteries to power the PCB. In between the motors, a 9-volt battery is used for the motor driver.

Theory

In control theory, holding some variable (in in this case robot position), a special controller called PID (proportional integral derivative) is required. Each of these parameters has a "gain", usually called Kp, Ki and Kd. The PID provides correction between the desired value (or input) and the actual value (or output). The difference between input and output is called "error".

The PID controller reduces the error to the smallest possible value by continuously adjusting the output. In our Arduino self-balancing robot, the input (which is the desired tilt in degrees) is set by software. The MPU6050 reads the robot's current tilt and feeds it to the PID algorithm, which performs calculations to control the motor and keep the robot upright.

The PID requires the Kp, Ki and Kd values ​​to be adjusted to optimal values. Engineers use software, such as MATLAB, to automatically calculate these values. Unfortunately, we cannot use MATLAB in our case because it will complicate the project even more. Instead, we will adjust the PID values. Here's how to do it:

  1. Make Kp, Ki and Kd equal to zero.
  2. Adjust Kp. Too small a Kp will cause the robot to fall because the correction is not enough. Too much Kp causes the robot to go wildly back and forth. A good Kp will make the robot move back and forth quite a bit (or oscillate a little).
  3. Once Kp is set, adjust Kd. A good Kd value will reduce the oscillations until the robot becomes almost stable. In addition, the correct Kd will hold the robot even if it is pushed.
  4. Finally, install Ki. When turned on, the robot will oscillate even if Kp and Kd are set, but will stabilize over time. Correct meaning Ki will reduce the time required to stabilize the robot.

The robot's behavior can be seen in the video below:

Arduino code for self-balancing robot

We needed four external libraries to create our robot. The PID library simplifies the calculation of P, I and D values. The LMotorController library is used to control two motors with the L298N module. The I2Cdev library and the MPU6050_6_Axis_MotionApps20 library are designed to read data from the MPU6050. You can download the code, including libraries, in this repository.

#include #include #include "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE #include "Wire.h" #endif #define MIN_ABS_SPEED 20 MPU6050 mpu; // MPU control/status vars bool dmpReady = false; // set true if DMP init was successful uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU uint8_t devStatus; // return status after each device operation (0 = success, !0 = error) uint16_t packetSize; // expected DMP packet size (default is 42 bytes) uint16_t fifoCount; // count of all bytes currently in FIFO uint8_t fifoBuffer; // FIFO storage buffer // orientation/motion vars Quaternion q; // quaternion container VectorFloat gravity; // gravity vector float ypr; //yaw/pitch/roll container and gravity vector //PID double originalSetpoint = 173; double setpoint = originalSetpoint; double movingAngleOffset = 0.1; double input, output; //adjust these values ​​to fit your own design double Kp = 50; double Kd = 1.4; double Ki = 60; PID pid(&input, &output, &setpoint, Kp, Ki, Kd, ​​DIRECT); double motorSpeedFactorLeft = 0.6; double motorSpeedFactorRight = 0.5; //MOTOR CONTROLLER int ENA = 5; int IN1 = 6; int IN2 = 7; int IN3 = 8; int IN4 = 9; int ENB = 10; LMotorController motorController(ENA, IN1, IN2, ENB, IN3, IN4, motorSpeedFactorLeft, motorSpeedFactorRight); volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high void dmpDataReady() ( mpuInterrupt = true; ) void setup() ( // join I2C bus (I2Cdev library doesn't do this automatically) #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin( ); TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz) #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire::setup(400, true); #endif mpu.initialize(); // supply your own gyro offsets here, scaled for min sensitivity mpu.setXGyroOffset(220); mpu.setYGyroOffset(-85); mpu.setZAccelOffset(1788); chip // make sure it worked (returns 0 if so) if (devStatus == 0) ( // turn on the DMP, now that it"s ready mpu.setDMPEnabled(true); // enable Arduino interrupt detectionInterrupt(0 , dmpDataReady, RISING); mpuIntStatus = mpu.getIntStatus(); // set our DMP Ready flag so the main loop() function knows it"s okay to use it dmpReady = true; // get expected DMP packet size for later comparison packetSize = mpu.dmpGetFIFOPacketSize(); //setup PID pid.SetMode(AUTOMATIC); pid.SetSampleTime(10); pid. SetOutputLimits(-255, 255); ) else ( // ERROR! // 1 = initial memory load failed // 2 = DMP configuration updates failed // (if it"s going to break, usually the code will be 1) Serial.print(F("DMP Initialization failed (code ")); Serial.print(devStatus); Serial.println(F()")); ) ) void loop() ( // if programming failed, don't try to do anything if (!dmpReady ) return; // wait for MPU interrupt or extra packet(s) available while (!mpuInterrupt && fifoCount< packetSize) { //no mpu data - performing PID calculations and output to motors pid.Compute(); motorController.move(output, MIN_ABS_SPEED); } // reset interrupt flag and get INT_STATUS byte mpuInterrupt = false; mpuIntStatus = mpu.getIntStatus(); // get current FIFO count fifoCount = mpu.getFIFOCount(); // check for overflow (this should never happen unless our code is too inefficient) if ((mpuIntStatus & 0x10) || fifoCount == 1024) { // reset so we can continue cleanly mpu.resetFIFO(); Serial.println(F("FIFO overflow!")); // otherwise, check for DMP data ready interrupt (this should happen frequently) } else if (mpuIntStatus & 0x02) { // wait for correct available data length, should be a VERY short wait while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount(); // read a packet from FIFO mpu.getFIFOBytes(fifoBuffer, packetSize); // track FIFO count here in case there is >1 packet available // (this lets us immediately read more without waiting for an interrupt) fifoCount -= packetSize; mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); input = ypr * 180/M_PI + 180; ) )

The Kp, Ki, Kd values ​​may or may not work. If they don't, follow the steps above. Note that the tilt in the code is set to 173 degrees. You can change this value if you wish, but note that this is the tilt angle that the robot must maintain. Also, if your motors are too fast, you can adjust the motorSpeedFactorLeft and motorSpeedFactorRight values.

That's all for now. See you.

Good day! In front of you, dear ones, is an art robot that can paint various spherical or ovoid objects ranging in size from 4 to 9 cm.

To make it you will need a 3D printer, a set of standard tools + Arduino.

Note: Do not give up on projects that use a 3D printer. If you wish, you can always find a place or way where you can order printing of the parts necessary for the project.

Step 1: A little about the robot

Art robot - two-axis homemade, which can pattern on most spherical surfaces. The robot is customized for a certain type of object (ping pong balls, Christmas decorations, light bulbs and eggs (duck, goose, chicken...).

High-precision stepper motors with high torque are used to rotate the spherical object and move the manipulator, and a quiet and reliable SG90 servo drive is used to lift the handle mechanism.

Step 2: Necessary Parts

In order to do DIY crafts we need:

  • 2x bearings 623;
  • Hairpin with a diameter of 3 mm and a length of 80-90 mm;
  • 1x spring (length 10 mm and diameter 4.5 mm);
  • 2x NEMA 17 stepper motors (torque 4.4 kg/cm);
  • Motor cables (length 14 + 70 cm);
  • USB cable;
  • 1x servo SG90;
  • Arduino Leonardo;
  • shield JJRobots;

  • 2xA4988 drivers for stepper motors;
  • Power supply 12V/2A;
  • 11x M3 6mm screws;
  • 4x M3 16mm screws;
  • 4x M3 nuts;
  • 2x 20mm suction cups;
  • 1x wing nut M3;
  • 1x marker;

Step 3: General outline

You can use this diagram as a “cheat sheet”.

Step 4: Let's get started!

The robot moves a manipulator with a marker attached to it, which is driven by a stepper motor. Another stepper motor is responsible for rotating the object on which the drawing is applied (egg, ball...). Two suction cups are used to hold the item in place: one attached to the stepper motor and the other on the opposite side of the item. A small spring will press against the suction cup, helping it hold the object. The SG90 servo drive is used to raise/lower the marker.

Step 5: Manipulator

Place the nut in the hole prepared for it and tighten the 16 mm screw. Let's do the same for the item holder (on the right in the image above). When creating the hinge for the manipulator, 2 16 mm screws were used. This hinge should rotate freely after tightening the screws.

Step 6: Suckers

Place one of the suction cups inside the hole in the item holder.

Step 7: Mounting the Stepper Motors

We attach both stepper motors to the main frame using 8 screws.

Step 8: Rotation Axis

Let's place all the elements as shown in the image above.

  • Sucker;
  • Screw;
  • Top part;
  • Spring;
  • Bearing 623 (must be built into the left cup);
  • Left cup;
  • Free space for the main frame;
  • Right cup;
  • Bearing 623;
  • Spacer ring;
  • Wing nut (M3).

Step 9: Putting everything in its place

Let's insert the assembled manipulator onto the axis of the stepper motor.

Let's install the left support on the axis of the stepper motor.

The marker and egg are set as an example (no need to place them now).

NOTE: The servo will require adjustments. You will need to re-set its angle during the calibration process.

Step 10: Electronics

Let's secure the electronics to the back of the main frame using screws (2 will be enough).

Let's connect the cables.

If you reverse the polarities when connecting stepper motors, they will simply rotate in the opposite direction, but with a servo drive the situation will not be so harmless! Therefore, double check the polarity before connecting!

Step 11: Programming the Arduino Leonardo

Let's program the Arduino Leonardo using the Arduino IDE (v 1.8.1).

  • Download Arduino IDE (v 1.8.1) and install the program;
  • Let's launch the software. Select the Arduino Leonardo board and the corresponding COM PORT in the “tools->board” menu;
  • Let's open and download the Sphere-O-Bot code. Let's unpack all the files inside one folder and call it “Ejjduino_ARDUINO”.

Step 12: The art robot is ready to create works of art

Step 13: Control the Robot

Software Inkscape. Let's download and install the Inkscape software (I recommend stable version 0.91).

Download and install the EggBot Control extension (version 2.4.0 has been fully tested).

The EggBot Control extension for Inkscape is the tool you need to use when testing and calibrating your EggBot and transferring your design onto the egg. First you need to launch Inkscape. After launching Inkscape, the “Extensions” menu will appear, and in it you need to select the “Eggbot” submenu. If you don't see the Eggbot submenu, then you haven't installed the extensions correctly. Execute backup and carefully follow the instructions for installing extensions.

That's all, thanks for your attention!)