Arduino programming using ArduBlok as an example of a robot moving along a strip

Hello! I am Alikin Alexander Sergeevich, teacher of additional education, I lead the circles "Robotics" and "Radio engineering" in the Center for Children and Youth Sports in Labinsk. I would like to talk a little about the simplified way of programming Arduino using the ArduBloсk program.

image

I introduced this program into the educational process and am delighted with the result; it is in special demand among children, especially when writing simple programs or for creating some initial stage of complex programs. ArduBloсk is a graphical programming environment, i.e., all actions are performed with painted pictures with signed actions in Russian, which greatly simplifies the study of the Arduino platform. Already from the 2nd grade, children easily learn how to work with Arduino thanks to this program.

Yes, someone can say that Scratch still exists and it is also a very simple graphical environment for programming Arduino. But Scratch does not flash Arduino, but only controls it via a USB cable. Arduino is computer dependent and cannot operate autonomously. When creating your own projects, autonomy for Arduino is the main thing, especially when creating robotic devices.

Even the well-known LEGO robots, such as NXT or EV3, are not so interesting for our students with the advent of the ArduBlok program in Arduino programming. Even Arduino is much cheaper than any LEGO constructors, and many components can simply be taken from old consumer electronics. The ArduBloсk program will help not only beginners, but also active users of the Arduino platform.

So what exactly is ArduBloсk?As I said, this is a graphical programming environment. Almost completely translated into Russian. But in ArduBloсk the highlight is not only this, but also that the ArduBloсk program that we wrote converts into Arduino IDE code. This program is embedded in the Arduino IDE programming environment, i.e. it is a plugin.

The following is an example of a flashing LED and a converted program in the Arduino IDE. All work with the program is very simple and any student will be able to understand it.

image

As a result of working on a program, you can not only program Arduino, but also study incomprehensible commands in the Arduino IDE text format, but if you are too lazy to write standard commands, you should quickly manipulate the mouse with a simple program to write into ArduBlok and debug it in Arduino IDE .

To install ArduBlok, you must first download and install the Arduino IDE from the Arduino official site and deal with the settings when working with the Arduino UNO board. How to do this is described on the same site or on Amperka , or watch on YouTube. Well, when you figured out all this, you need to download ArduBlok from the official site, here is the link . I do not recommend downloading the latest versions, for beginners they are very complicated, but the version from 2013-07-12 is the most popular, this file is the most popular there.

Then, we rename the downloaded file to ardublock-all and in the “documents” folder. We create the following folders: Arduino> tools> ArduBlockTool> tool and in the last we throw the downloaded and renamed file. ArduBlok works on all operating systems, even on Linux, personally tested it on XP, Win7, Win8, all examples for Win7. The installation of the program is the same for all systems.

image

Well, and if it's easier, I prepared an archive on the Mail-disk 7z , unpacking which you will find 2 folders. In one, the Arduino IDE is already working, and in another folder, the contents must be sent to the documents folder.

In order to work in ArduBlok, you must run the Arduino IDE. Then we go to the Tools tab and there we find the ArduBlok item, click on it - and here it is, our goal.

image

Now let's deal with the program interface. As you already understood, there are no settings in it, but there are plenty of icons for programming and each of them carries a command in the Arduino IDE text format. There are even more icons in new versions, so it’s difficult to deal with the latest version of ArduBlok and some of the icons are not translated into Russian.

image

In the section "Management" we will find a variety of cycles.

image

In the “Ports” section, we can manage the values ​​of the ports, as well as the sound emitter, servo machine or ultrasonic proximity sensor connected to them.

image

In the "Numbers / Constants" section, we can choose digital values ​​or create a variable, but the fact that below is unlikely to be used.

image

In the "Operators" section, we will find all the necessary comparison and calculation operators.

image

The Utilities section mainly uses icons over time.

image

TinkerKit Bloks is the section for purchased TinkerKit kit sensors. Of course, we don’t have such a kit, but this does not mean that the icons will not work for other sets, on the contrary, it’s very convenient for the guys to use such icons as the LED or button. These signs are used in almost all programs. But they have a peculiarity - when they are selected, the wrong icons indicate the ports, so you need to remove them and substitute the icon from the "numbers / constants" section at the top of the list.



“DF Robot” - this section is used in the presence of the sensors indicated in it, they are sometimes found. And our current example is no exception, we have an “Adjustable IR Switch” and a “Line Sensor”. The “Line Sensor” is different from the one in the picture, since it is from Amperka. Their actions are identical, but the sensor from Amperka is much better, since it has a sensitivity regulator.



Seeedstudio Grove - I have never used the sensors in this section, although there are only joysticks. In new versions, this section is expanded.



And the last section is the Linker Kit. The sensors presented in it, I did not come across.

I would like to show an example of a program on a robot moving in a strip. The robot is very simple, both in assembly and in acquisition, but first things first. Let's start with its acquisition and assembly.

Here is the set of parts itself; everything was purchased on the Amperka website .



  1. AMP-B001 Motor Shield (2 channels, 2 A) 1 890 rub
  2. AMP-B017 Troyka Shield 1 690 rub
  3. AMP-X053 Battery compartment 3 × 2 AA 1 60 rub
  4. AMP-B018 Line Sensor Digital 2 580 rub
  5. ROB0049 Two-wheel platform miniQ 1 1890 rub
  6. SEN0019 Infrared obstacle sensor 1 390 rub
  7. FIT0032 Mount for infrared obstacle sensor 1 90 rub
  8. A000066 Arduino Uno 1 1150 rub




To begin with, we will assemble the wheel platform and solder the wires to the engines.



Then install the racks for mounting the Arduino UNO board, which were taken from the old motherboard or some other similar mounts.



Then we attach the Arduino UNO board to these racks, but one screw cannot be screwed on - the connectors interfere. You can, of course, get them out, but that's up to you.



Next we attach the infrared obstacle sensor to its special mount. Please note that the sensitivity control is on top, this is for easy adjustment.





Now we install digital line sensors, here we have to look for a pair of bolts and 4 nuts for them. We install two nuts between the platform itself and the line sensor, and fix the rest with the rest.



Next install Motor Shield, or in another way you can call the engine driver. In our case, pay attention to the jumper. We will not use separate power for the engines, so it is installed in this position. The lower part is sealed with electrical tape, so that there are no accidental short circuits from the Arduino UNO USB connector, just in case.





Top Motor Shield install Troyka Shield. It is necessary for the convenience of connecting sensors. All the sensors we use are digital, so the line sensors are connected to port 8 and 9, as they are also called pins, and the infrared obstacle sensor is connected to port 12. Be sure to note that ports 4, 5, 6, 7 cannot be used since they are used by Motor Shield to control engines. I even specially painted over these ports with a red marker so that the students could figure it out.



If you have already noticed, I added a black sleeve, just in case, so that the battery compartment that we installed does not fly out. And finally, we fix the entire structure with an ordinary rubber band.

Connecting the battery compartment can be of 2 types. First connection of wires to the Troyka Shield. It is also possible to solder the power plug and connect it to the Arduino UNO board itself.





Here is our robot ready. Before you start programming, you will need to study how everything works, namely:
- Motors:
Port 4 and 5 are used to control one motor, and 6 and 7 to another;
We regulate the engine speed with PWM on ports 5 and 6;
Forward or backward, giving signals to ports 4 and 7.
- Sensors:
We have everything digital, therefore they give logical signals in the form of 1 or 0;
And in order to adjust them, they have special regulators and with a suitable screwdriver they can be calibrated.

Details can be found onAmperke . Why is it here? Because there is a lot of information on working with Arduino.

Well, we, perhaps, looked through everything superficially, studied and, of course, assembled a robot. Now it needs to be programmed, here it is - a long-awaited program!



And the program converted to Arduino IDE:

void setup()
{
pinMode( 8 , INPUT);
pinMode( 12 , INPUT);
pinMode( 9 , INPUT);
pinMode( 4 , OUTPUT);
pinMode( 7 , OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
}
void loop()
{
if (digitalRead( 12))
{
if (digitalRead( 8))
{
if (digitalRead( 9))
{
digitalWrite( 4 , HIGH );
analogWrite(5, 255);
analogWrite(6, 255);
digitalWrite( 7 , HIGH );
}
else
{
digitalWrite( 4 , HIGH );
analogWrite(5, 255);
analogWrite(6, 50);
digitalWrite( 7 , LOW );
}
}
else
{
if (digitalRead( 9))
{
digitalWrite( 4 , LOW );
analogWrite(5, 50);
analogWrite(6, 255);
digitalWrite( 7 , HIGH );
}
else
{
digitalWrite( 4 , HIGH );
analogWrite(5, 255);
analogWrite(6, 255);
digitalWrite( 7 , HIGH );
}
}
}
else
{
digitalWrite( 4 , HIGH );
analogWrite(5, 0);
analogWrite(6, 0);
digitalWrite( 7 , HIGH );
}
}


In conclusion, I want to say that this program is just a godsend for education, even for self-study, it will help to learn the commands of the Arduino IDE. The most important highlight is that more than 50 installation icons, it starts to “fail”. Yes, indeed, this is a highlight since constant programming only on ArduBlok will not teach you programming in the Arduino IDE. The so-called "glitch" makes it possible to think and try to memorize commands for fine debugging of programs.

Wish you success.


Also popular now: