The most interesting Arduino projects. Arduino for Beginners: Step-by-Step Instructions

My fascination with the Arduino platform led me to devices operating on the I2C bus (short for Inter-Integrated Circuit), also called “Two-Wire” devices. A large number of microcircuits are produced that support the I2C bus in hardware. These include all kinds of sensors, real-time clocks, memory, port expanders and much more. The article below presents a modernization of the project for a device scanner with an I2C bus based on Arduino, which is described on the page http://playground.arduino.cc/Main/I2cScanner and an example of practical work with a device prototype independent from a computer.

The control program, remote control methods (bluetooth or APC220), everything remains the same.

The article has added diagrams and program codes for transferring the project to common motor control chambers ( and )

Read

Automatic watering of plants

A couple of years ago I became interested in breeding various exotic plants. Fortunately, the window sills (almost half a meter by one and a half) allow you to place quite a lot of pots. But last year, as Muscovites may remember, the heat was not weak. Since I work in an office, I was only able to water in the morning and evening. And this was clearly not enough.

Plus also trips to the country for the weekend... And just one half-meter eucalyptus bush is capable of evaporating 2-3 liters of water in two days and night and having time to wither.

I didn’t like the wick system because it is unadjustable and eats up space on the window. Which is already in short supply. Watering cans-pipettes of the plant genie type were not suitable due to the fact that even having learned the trick of sticking them into a pot (stuck it wrong - either it doesn’t drip or leaks out in a couple of hours), you either need so many of them that there is not enough area of ​​the pot or the pot is small and just turns over. Well, this 0.22l is also not really enough for the stated two weeks.

In this article, I decided to put together a complete step-by-step guide for Arduino beginners. We will look at what Arduino is, what you need to start learning, where to download and how to install and configure the programming environment, how it works and how to use the programming language, and much more that is necessary to create full-fledged complex devices based on the family of these microcontrollers.

Here I will try to give a condensed minimum so that you understand the principles of working with Arduino. For a more complete immersion in the world of programmable microcontrollers, pay attention to other sections and articles of this site. I will leave links to other materials on this site for a more detailed study of some aspects.

What is Arduino and what is it for?

Arduino is an electronic construction kit that allows anyone to create a variety of electro-mechanical devices. Arduino consists of software and hardware. The software part includes a development environment (a program for writing and debugging firmware), many ready-made and convenient libraries, and a simplified programming language. The hardware includes a large line of microcontrollers and ready-made modules for them. Thanks to this, working with Arduino is very easy!

With the help of Arduino you can learn programming, electrical engineering and mechanics. But this is not just an educational constructor. Based on it, you can make really useful devices.
Starting from simple flashing lights, weather stations, automation systems and ending with smart home systems, CNC machines and unmanned aerial vehicles. The possibilities are not even limited by your imagination, because there are a huge number of instructions and ideas for implementation.

Arduino Starter Kit

In order to start learning Arduino, you need to acquire the microcontroller board itself and additional parts. It is best to purchase an Arduino starter kit, but you can choose everything you need yourself. I recommend choosing a set because it's easier and often cheaper. Here are links to the best sets and individual parts that you will definitely need to study:

Basic Arduino kit for beginners:Buy
Large set for training and first projects:Buy
Set of additional sensors and modules:Buy
Arduino Uno is the most basic and convenient model from the line:Buy
Solderless breadboard for easy learning and prototyping:Buy
Set of wires with convenient connectors:Buy
LED set:Buy
Resistor kit:Buy
Buttons:Buy
Potentiometers:Buy

Arduino IDE development environment

To write, debug and download firmware, you need to download and install the Arduino IDE. This is a very simple and convenient program. On my website I have already described the process of downloading, installing and configuring the development environment. Therefore, here I will simply leave links to the latest version of the program and to

Version Windows Mac OS X Linux
1.8.2

Arduino programming language

When you have a microcontroller board in your hands and a development environment installed on your computer, you can start writing your first sketches (firmware). To do this, you need to become familiar with the programming language.

Arduino programming uses a simplified version of the C++ language with predefined functions. As in other C-like programming languages, there are a number of rules for writing code. Here are the most basic ones:

  • Each instruction must be followed by a semicolon (;)
  • Before declaring a function, you must specify the data type returned by the function, or void if the function does not return a value.
  • It is also necessary to indicate the data type before declaring a variable.
  • Comments are designated: // Inline and /* block */

You can learn more about data types, functions, variables, operators and language constructs on the page on You do not need to memorize and remember all this information. You can always go to the reference book and look at the syntax of a particular function.

All Arduino firmware must contain at least 2 functions. These are setup() and loop().

setup function

In order for everything to work, we need to write a sketch. Let's make the LED light up after pressing the button, and go out after the next press. Here's our first sketch:

// variables with pins of connected devices int switchPin = 8; int ledPin = 11; // variables to store the state of the button and LED boolean lastButton = LOW; boolean currentButton = LOW; boolean ledOn = false; void setup() ( pinMode(switchPin, INPUT); pinMode(ledPin, OUTPUT); ) // function for debouncing boolean debounse(boolean last) ( boolean current = digitalRead(switchPin); if(last != current) ( delay (5); current = digitalRead(switchPin); ) return current ) void loop() ( currentButton = debounse(lastButton); if(lastButton == LOW && currentButton == HIGH) ( ledOn = !ledOn; ) lastButton = currentButton ; digitalWrite(ledPin, ledOn);

// variables with pins of connected devices

int switchPin = 8 ;

int ledPin = 11 ;

// variables to store the state of the button and LED

boolean lastButton = LOW ;

boolean currentButton = LOW ;

boolean ledOn = false ;

void setup() (

pinMode(switchPin, INPUT);

pinMode(ledPin, OUTPUT);

// function for debouncing

boolean debounse (boolean last ) (

boolean current = digitalRead(switchPin);

if (last != current ) (

delay(5);

current = digitalRead(switchPin);

return current ;

void loop() (

currentButton = debounse(lastButton);

if (lastButton == LOW && currentButton == HIGH ) (

ledOn = ! ledOn ;

lastButton = currentButton ;

digitalWrite(ledPin, ledOn);

In this sketch, I created an additional debounse function to suppress contact bounce. There is information about contact bounce on my website. Be sure to check out this material.

PWM Arduino

Pulse width modulation (PWM) is the process of controlling voltage using the duty cycle of a signal. That is, using PWM we can smoothly control the load. For example, you can smoothly change the brightness of an LED, but this change in brightness is obtained not by decreasing the voltage, but by increasing the intervals of the low signal. The operating principle of PWM is shown in this diagram:

When we apply PWM to the LED, it starts to quickly light up and go out. The human eye is not able to see this because the frequency is too high. But when shooting video, you will most likely see moments when the LED is not lit. This will happen provided that the camera frame rate is not a multiple of the PWM frequency.

Arduino has a built-in pulse width modulator. You can use PWM only on those pins that are supported by the microcontroller. For example, Arduino Uno and Nano have 6 PWM pins: these are pins D3, D5, D6, D9, D10 and D11. The pins may differ on other boards. You can find a description of the board you are interested in in

To use PWM in Arduino there is a function. It takes as arguments the pin number and the PWM value from 0 to 255. 0 is 0% fill with a high signal, and 255 is 100%. Let's write a simple sketch as an example. Let's make the LED light up smoothly, wait one second and fade out just as smoothly, and so on ad infinitum. Here is an example of using this function:

// The LED is connected to pin 11 int ledPin = 11; void setup() ( pinMode(ledPin, OUTPUT); ) void loop() ( for (int i = 0; i< 255; i++) { analogWrite(ledPin, i); delay(5); } delay(1000); for (int i = 255; i >0; i--) ( analogWrite(ledPin, i); delay(5); ) )

// LED connected to pin 11

int ledPin = 11 ;

void setup() (

pinMode(ledPin, OUTPUT);

void loop() (

for (int i = 0 ; i< 255 ; i ++ ) {

analogWrite(ledPin, i);

delay(5);

delay(1000);

for (int i = 255; i > 0; i -- ) (

Today we will talk about traffic light on on DigiSpark and WS2812 addressable LEDs . This is the second version traffic light. I talked about the first one here. The first version turned out to be quite convenient and consisted of fewer parts. Why did I decide to make a second version? The fact is that the box holds the batteries that I used in the first version traffic light on Arduino, has become very expensive. Some sellers sell it for $5 on . More expensive than all other electronics. So I decided to change the box to a cheaper one. And once I had to redo the body. I decided to change the size of the traffic light itself and make it larger than the first version. Also in the leg traffic light added a metal rod to increase rigidity.

Alarm clock on Arduino. The body is made from LEGO construction kits. LEGO Arduino

My 5-year-old child came from kindergarten and said that he was asked to make a project for smart devices in the house. The body can be made from any available construction kit. Can be made from LEGO designer. After some thought, my son and I decided to do alarm clock on Digispark And 7 segment indicator on TM1637 With real time clock DS3231.

New Arduino projects and Projects made on a CNC machine

Summer is over. And time to develop Arduino projects become bigger. And today I plan to talk about my new projects which I do on Arduino and yours homemade CNC machine. Projects are still in the development stage and do not have a final finished form. But still, I decided to talk about them so that I could hear an outside opinion.

Traffic light on Digispark and addressable LEDs WS2812 - Arduino traffic light

In the previous article: " » I already talked about the development traffic light and that I was unable to make it fully functional and operational. After a couple of weeks I finalized it and now I'm ready to present it homemade traffic light using Arduino and WS2812 addressable LEDs.

I cut all the blanks for the body on my own homemade CNC machine.

Unsuccessful Arduino lamp and traffic light projects

Any development leads to unsuccessful and intermediate models. Which do not satisfy all needs and expectations.

Good day, Habr. I am launching a series of articles that will help you get acquainted with Arduino. But this does not mean that if you are not new to this business, you will not find anything interesting for yourself.

Introduction

It would be a good idea to start by getting acquainted with Arduino. Arduino – hardware and software for building automation and robotics systems. The main advantage is that the platform is aimed at non-professional users. That is, anyone can create their own robot, regardless of programming knowledge and their own skills.

Start

Creating a project on Arduino consists of 3 main stages: writing code, prototyping (breadboarding) and firmware. In order to write code and then flash the board, we need a development environment. In fact, there are quite a few of them, but we will program in the original environment - Arduino IDE. We will write the code itself in C++, adapted for Arduino. You can download it on the official website. A sketch is a program written on Arduino. Let's look at the code structure:


main())( void setup())( ) void loop())( ) )

It is important to note that the Arduino processor creates the main() function, which is required in C++. And the result of what the programmer sees is:


void setup() ( ) void loop() ( )

Let's look at the two required functions. The setup() function is called only once when the microcontroller starts. It is she who sets all the basic settings. The loop() function is cyclic. It is called in an endless loop throughout the entire operating time of the microcontroller.

First program

In order to better understand the operating principle of the platform, let's write the first program. We will execute this simplest program (Blink) in two versions. The only difference between them is the assembly.


int Led = 13; // declare the Led variable on pin 13 (output) void setup() ( pinMode(Led, OUTPUT); // define the variable ) void loop() ( digitalWrite(Led, HIGH); // apply voltage to pin 13 delay(1000 ); // wait 1 second digitalWrite(Led, LOW); // do not apply voltage to pin 13 delay(1000); // wait 1 second)

The operating principle of this program is quite simple: the LED lights up for 1 second and goes out for 1 second. For the first option, we do not need to assemble a layout. Since the Arduino platform has a built-in LED connected to pin 13.

Arduino firmware

In order to upload a sketch to Arduino, we first need to simply save it. Next, to avoid problems during loading, you need to check the programmer settings. To do this, select the “Tools” tab on the top panel. In the “Payment” section, select your payment. It could be Arduino Uno, Arduino Nano, Arduino Mega, Arduino Leonardo or others. Also in the “Port” section you need to select your connection port (the port to which you connected your platform). After these steps, you can upload the sketch. To do this, click on the arrow or select “Download” in the “Sketch” tab (you can also use the keyboard shortcut “Ctrl + U”). The board firmware has been completed successfully.

Prototyping/layout

To assemble the breadboard, we need the following elements: LED, resistor, wiring (jumpers), breadboard. In order not to burn anything, and in order for everything to work successfully, you need to deal with the LED. It has two "legs". Short is a minus, long is a plus. We will connect the ground (GND) and a resistor to the short one (in order to reduce the current supplied to the LED so as not to burn it), and we will supply power to the long one (connect to pin 13). After connecting, upload the sketch to the board if you have not done so previously. The code remains the same.


This is the end of the first part. Thank you for your attention.

Arduino is very popular among all design enthusiasts. Those who have never heard of it should also be introduced to it.

What is Arduino?

How can you briefly describe Arduino? The best words would be: Arduino is a tool that can be used to create various electronic devices. In essence, this is a true general-purpose hardware computing platform. It can be used both for constructing simple circuits and for implementing quite complex projects.

The designer is based on its hardware, which is an input-output board. To program the board, languages ​​that are based on C/C++ are used. They are called, respectively, Processing/Wiring. From group C they inherited extreme simplicity, thanks to which they can be mastered very quickly by any person, and applying knowledge in practice is not a rather significant problem. So that you understand the ease of work, it is often said that Arduino is for beginner wizard-designers. Even children can understand Arduino boards.

What can you collect on it?

The applications of Arduino are quite diverse; it can be used both for the simplest examples, which will be recommended at the end of the article, and for quite complex mechanisms, including manipulators, robots or production machines. Some craftsmen manage to use such systems to make tablets, phones, home surveillance and security systems, smart home systems, or simply computers. Arduino projects for beginners, which even those with no experience can get started with, are at the end of the article. They can even be used to create primitive virtual reality systems. All thanks to the fairly versatile hardware and capabilities that Arduino programming provides.

Where can I buy the components?

Components made in Italy are considered original. But the price of such kits is not low. Therefore, a number of companies or even individuals make artisanal methods of Arduino-compatible devices and components, which are jokingly called production clones. When purchasing such clones, one cannot say with certainty that they will work, but the desire to save money takes its toll.

Components can be purchased either as part of kits or separately. There are even pre-prepared kits for assembling cars, helicopters with different types of controls, or ships. A set like the one pictured above, made in China, costs $49.

More about the equipment

The Arduino board is a simple AVR microcontroller, which has been flashed with a bootloader and has the minimum required USB-UART port. There are other important components, but within the scope of the article it would be better to focus only on these two components.

First, about the microcontroller, a mechanism built on a single circuit in which the developed program is located. The program can be influenced by pressing buttons, receiving signals from the components of the creation (resistors, transistors, sensors, etc.), etc. Moreover, the sensors can be very different in their purpose: lighting, acceleration, temperature, distance, pressure, obstacles etc. Simple parts can be used as display devices, from LEDs and tweeters to complex devices such as graphic displays. The quality considered are motors, valves, relays, servos, electromagnets and many others, which would take a very, very long time to list. The MK works directly with some of these lists, using connecting wires. Some mechanisms require adapters. But once you start designing, it will be difficult for you to tear yourself away. Now let's talk about Arduino programming.

Learn more about the board programming process

A program that is already ready to run on a microcontroller is called firmware. There can be either one project or Arduino projects, so it would be advisable to store each firmware in a separate folder to speed up the process of finding the necessary files. It is flashed onto the MK crystal using specialized devices: programmers. And here Arduino has one advantage - it does not need a programmer. Everything is done so that programming Arduino for beginners is not difficult. The written code can be loaded into the MK via a USB cable. This advantage is achieved not by some pre-built programmer, but by special firmware - a bootloader. The bootloader is a special program that starts immediately after connection and listens to whether there are any commands, whether to flash the crystal, whether there are Arduino projects or not. There are several very attractive advantages to using a bootloader:

  1. Using only one communication channel, which does not require additional time costs. So, Arduino projects do not require you to connect many different wires and there will be confusion when using them. One USB cable is enough for successful operation.
  2. Protection from crooked hands. It’s quite easy to bring the microcontroller to a brick state using direct firmware; you don’t need to work hard. When working with a bootloader, you will not be able to access potentially dangerous settings (with the help of a development program, of course, otherwise everything can be broken). Therefore, Arduino for beginners is intended not only from the point of view that it is understandable and convenient, it will also allow you to avoid unwanted financial expenses associated with the inexperience of the person working with them.

Projects to get started

When you have acquired a kit, a soldering iron, rosin and solder, you should not immediately sculpt very complex structures. Of course, you can make them, but the chance of success in Arduino for beginners is quite low with complex projects. To train and improve your skills, you can try to implement a few simpler ideas that will help you understand the interaction and operation of Arduino. As the first steps in working with Arduino for beginners, we can advise you to consider:

  1. Create one that will work thanks to Arduino.
  2. Connecting a separate button to Arduino. In this case, you can make it so that the button can adjust the glow of the LED from point No. 1.
  3. Potentiometer connection.
  4. Servo control.
  5. Connecting and working with a three-color LED.
  6. Connecting the piezoelectric element.
  7. Connecting a photoresistor.
  8. Connecting a motion sensor and signals about its operation.
  9. Connecting a humidity or temperature sensor.

Projects for the future

It is unlikely that you are interested in Arduino in order to connect individual LEDs. Most likely, you are attracted by the opportunity to create your own car, or flying turntable. These projects are difficult to implement and will require a lot of time and perseverance, but once completed, you will get what you want: valuable Arduino design experience for beginners.