💡 How to connect RGB LED to Arduino

Daniil Zhuk
RGB LED - these are three LEDs of different colors (Red - red, Green - green, Blue - blue), enclosed in one package. Let's see how to connect the RGB LED to the Arduino.

Read more →

☀️ Home-made light meter (luxmeter) on the BH1750, ARDUINO and Nokia 5110

Daniil Zhuk
Today we will continue to create cool devices based on the Nokia 5110 LCD display. This time we will assemble a luxmeter (the light meter) using a high-sensitive BH1750 luxmeter.

Read more →

💻 Circuito.io - an online rapid prototyping service on Arduino

Daniil Zhuk

Arduino is a company that creates single-board controllers and kits based on microcontrollers. And these kits come in a do-it-yourself form. The Arduino platform can be used by almost everyone since it is inexpensive and easy to use for both professionals and amateurs. But, despite the fact that the Arduino sets come in already assembled form, you can get bogged down in the search for ideas for a project or experiment.

The situation when there are no ideas is not so rare and sometimes leads young DIY artists to a stupor. Arduino supplies open source hardware and software but does not provide ideas that can be applied to it. This makes the sets useless.

In most cases, there is an understanding of the necessary components, but there is a problem of how to connect them. This is where the site circuito.io comes to the rescue. Imagine a platform that allows you to create the most interesting projects by simply selecting the components that you are going to use, connects them themselves and writes the basic code.

Circuito.io is an online prototype development tool for Arduino. The Circuito app instantly generates a mockup and code for your device. You just select the main component blocks, the entire connection and configuration process is taken over by the application.

Circuito.io has an intuitive interface that allows you to drag and drop various elements together using drag and drop. The work consists of three sections that must be passed before proceeding with the testing of the device. The first is the material specification (BoM - Bill of Materials), called DESIGN.

Here from the components available in the application, you select the ones you need. You select the components that are needed or over which you think they will be needed and go on. The next section (Wire - wire) is a tool that makes up the electrical circuit and adds all the necessary elements; at the exit, you get a well-marked electrical circuit.

Another very convenient feature of the service is the circuito.io platform interface that allows you to step through each component and help you in the process of creating the device. You are working not just with a static scheme, but you can move in different directions.

However, this is not all! After drawing up the scheme, the CODE section (program code) follows, which gives you a programming example for each component from the previous section. The platform will solve the problems of hundreds of users of Arduino sets, and with its help, it will become much easier to program your device, thanks to code examples for various components.

It turns out that the platform also serves as a learning tool for beginners. So, if you are stuck thinking about how a project based on Arduino sets can work, the circuito.io application may be just what you need.

Read more →

🙂 Flashing LED on the Arduino board

Daniil Zhuk

Hello! In this article, we will blink an LED! Now for many of you, this will seem banal and a mere trifle, you will laugh at those who repeat it again and again. Now, remember how you yourself tried to do it a few years ago?

Perhaps it did not work out the first time: the incorrect setting of the board in the development environment, searching for the desired resistor, installing drivers on the board, etc. But when the LED started to flash ... Oh, yes! And if we compare the people who lived in the Soviet Union with the current generation, then ours had the best childhood — they blinked with a LED 🙂

Let's go back to this “golden time” and once again feel this sweet taste of victory!

Blink we will be the LED built into the Arduino board. It is also indicated on the board by the letter L.

Actually, in addition to the board, we will need a computer with an installed Arduino IDE development environment and a USB cable for interfacing our devices.

Go to the Arduino IDE. There is no need to install anything else. Now we go to the file -> examples -> built-in examples -> Basics -> Blink.

What is in the archive? To begin with, I note that in any code for Arduino there must be two mandatory functions: void setup () and void loop (). The first one registers what is executed only once when the board is turned on. In the second, that will be performed continuously, cyclically. Before the void setup () function, variables are written that need to be used in the code (sketch), various libraries are connected, arrays are specified - in general, any data that we will use in the code. As you understand, in our code, nothing like this is required.

There are 14 digital pins on the Arduino Uno board (from D0 to D13). Analog contacts are also available (labeled A0 to A5). At the outputs of digital contacts can be two values ​​- HiGH or LOW. At the outputs of the analog, there is support for pulse-width modulation, which allows processing and reading from a variety of sensors a variety of values. For the LED, we need only one thing - to turn it on or off.

Therefore, we will connect it to a digital contact. To contacts from 0 to 12, you can connect external LEDs through a 220 Ohm resistor. Pin 13 includes the LED already built into the board, which we talked about earlier. Using the pinMode function, we specify the type of digital output as output, since the LED will execute our commands, this is the load that waits for instructions (the same is indicated, for example, when the relay is connected).

Next is the cycle. As mentioned earlier, on the digital contact we can adjust two values. High logic level (HiGH) and low logic level (LOW) set the maximum value of the voltage (5V) on it and the minimum (0V), respectively.

When HiGH is set, the maximum voltage is applied and the LED is on. If LOW, the minimum value is applied and the LED goes out.

In order to see how it flashes - set the delay using the function delay (1000). This command pauses the operation of the code for the time that is written in brackets, in other words, it pauses our code. The time in milliseconds is indicated in brackets (1000 milliseconds = 1 second). When the HIGH state turns on, and then a pause of 1 second turns on, then, since the state on the LED output has not changed, the LED will light for exactly 1 second. Then it turns off for 1 second, turns on again, and so on. So we get, it flashes. Happened!

I have it all. If you liked the article, then look at other, more informative articles in our blog. Thank you all for your attention and successful compilation!

Read more →

LED matrix MAX7219 - connection to Arduino

Daniil Zhuk
Sooner or later there is a need to output data from the Arduino and display them on a relatively large display. Large size displays cost a lot for hobby projects, so one of the best options is an LED display.

Read more →

🔘 Connecting button to Arduino

Daniil Zhuk
When you are just starting to get acquainted with Arduino, then your first scheme will most likely be connecting the LED to the board and flashing it at the frequency you specify in the program code.

Read more →

🚥 Arduino and LED address strip WS2812B

Daniil Zhuk

In this article, we will learn how to work with addressable LED RGB tape WS2812B. The tape consists of RGB pixels WS2812B in an LED 5050 package (the physical dimensions of each element are 5 × 5 mm).

Each pixel contains red, green and blue LEDs and a PWM controller, with which you can control the brightness of each LED and get a lot of different colors from the three main ones.

Since each WS2812B consists of three LEDs and a PWM controller, it is better to call them pixels rather than LEDs. In the photo on the right, you can see the device of this pixel.

A little about the characteristics of the address LEDs WS2812B:

  • Power supply: 5 ± 0.5 V;
  • Current consumption: ~ 20 mA one LED, i.e. ~ 60 mA whole pixel.

At the beginning, we need to connect the LEDs to the Arduino. Make it extremely simple. Contacts + 5V and GND are connected to the positive and negative power supply, respectively. Din is connected to an Arduino digital pin, by default it will be the 6th digital pin, but youcan use any other.

In addition, it is advisable to connect the ground of the Arduino with the ground of the power source. It is undesirable to use the Arduino as a power source since the + 5V output can provide only 800 mA of current. This is enough for no more than 13 pixels of the LED strip.

On the other side of the tape, there is a Do output, it connects to the next tape, allowing you to control the tapes in a cascade manner, like one. The power connector at the end is also duplicated.


Next, we will deal with the management of the tape. A description of the control protocol is present in the Datasheet for WS2812B.

All pixels are by default connected to each other in series. Din input of each of them is connected to the output Do of the next. The control signal must come to the first one.

Control commands are given in packets of 3 bytes, one for each of the three colors. Between packets, there is a pause with a duration of 50 µs, a pause of more than 100 µs means the end of the transmission.

The duration of any bit is 1.25 µs. A bit “1” is encoded by a pulse with a duration of 0.8 μs and a pause of 0.45 μs. The “0” bit is 0.4 and 0.85 μs. Time differences up to 150 ns are possible. Such a packet must be sent for each pixel in the LED strip. The diagram shows the desired signal.

Most Popular Libraries:


Supports all versions of Arduino and a variety of data transfer protocols (not only for our tape). The programming language in which it is written is pure C.

Adafruit NeoPixel

The library is designed to work with LED rings NeoPixel Ring, the development and production of Adafruit. It works slower, has less power, but contains only the most necessary. Written in C, assembly language and some Wiring. Supports the entire line of Arduino.


Let's try both libraries and compare them. Let's write a standard Blink sketch so that the tape lights up red for half a second and turns off for the same interval.

By default, the number of pixels in the tape is 30, but if necessary it can be changed in the sketch.

An example using the FastLED library:

#include "FastLED.h"
#define LED_COUNT 30
#define LED_PIN 6

void setup()
FastLED.addLeds<WS2812B, LED_PIN, RGB>(strip, LED_COUNT);

void loop()
for (int i = 0; i < LED_COUNT; i++)
strip[i] = CRGB::Red; 
for (int i = 0; i < LED_COUNT; i++)
strip[i] = CRGB::Black;

The sketch will occupy 3758 bytes in program memory of Arduino and 187 bytes of RAM.

Now let's try the same thing with the Adafruit NeoPixel library:

#include "Adafruit_NeoPixel.h"

#define LED_COUNT 30

#define LED_PIN 6

Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup()

void loop()
for (int i = 0; i < LED_COUNT; i++)
strip.setPixelColor(i, strip.Color(255, 0, 0)); 
for (int i = 0; i < LED_COUNT; i++)
strip.setPixelColor(i, strip.Color(0, 0, 0));

The sketch will take 2592 permanent and 40 bytes of Arduino RAM.

As you can see, the FastLED library is more resource-intensive. In addition, using it in Arduino with 2 KB of RAM (such as, for example, UNO), you can control up to 600 pixels of the LED strip. This is due to the fact that 3 bytes of memory are reserved for each pixel.

But in Adafruit NeoPixel the minimum necessary functions and less memory consumption. Which one to use is your choice.

Read more →

Arduino and GSM module SIM900A. How to flash and use?

Daniil Zhuk
In this article, I will talk about working with the GSM-module SIM900A. With it, you can make automated calls and send messages in the same way. Also, it supports the GPRS protocol.

Read more →

💡 Automatic staircase lighting with Arduino

Daniil Zhuk2 comments

In this post, I want to share with the Internet community about how I happened to make automatic lighting of the stairs in my two-story cottage. About four months ago, returning from work in complete darkness, I did not slip well and broke two metatarsal bones (fingers) on my left foot. The whole month had to fall into bed, as stepping on my foot was incredibly painful. Then he was limp without a plaster for another half month (those who had fractures would immediately understand me). After this sad story, I began to think about the automation of staircase lighting. After playing a little with search queries, I found a very simple solution for myself on this blog, just based on my favorite Arduino microcontroller. The scheme did not cause any difficulties, but it scared the number and length of the wires that I had to mount. Before that, I did not do anything like that. Buying ready-made solutions or hiring someone is expensive. Within a month I ordered the necessary components and unhurriedly assembled it on my stairs in a few days. Everyone who is interested in what came of it, welcome to the cut!


I will give an approximate cost of all the components that were used in the work. Most of the components purchased in the shops in my city so I will give everything in rubles.

Arduino pro mini
HC-SR04 — 2x
LED driver L5450
Voltage regulator L78M05CV
Cable channel 20 × 10 mm - 10 M
Wire 2 × 0.12 - 100 M (with a margin for tapes)
4 × 0.12 - 20 M wire (for sensors)
LED Strip LSP0603W15 White - 17 pieces of 30 cm
Small things: textolite 15 × 15 cm, ferric chloride, 0.9 mm drill bit, PLS type pin connectors, BLS connectors, heat shrink tubing, capacitors and resistors
The power supply unit 12B (it is the case) from the Parus 4 alarm system


I debugged the firmware for Arduino, like everything else, on a breadboard using ordinary LEDs.


With the help of the notorious environment for the design of Eagle CAD, the author’s scheme and printed circuit board were improved. Here I added a voltage regulator to 5 V, changed the sensors from 3-pin expensive Ping to four-pin cheap HC-SR04. In order for the staircase lighting to work only in the dark, a Soviet photoresistor FR-764 was added to the circuit (you can also use another one).




The sketch uses a freely distributed library for working with the LED driver M5450, as well as a library for working with the ultrasonic range finder HC-SR04.

#include "lightuino3.h"
#include "Ultrasonic.h"
//Устанавливаем контакты для первого датчика
#define  TRIG_PIN  12
#define  ECHO_PIN  13
//Устанавливаем контакты для второго датчика
#define  TRIG2_PIN  10
#define  ECHO2_PIN  11
//Определяем первый датчик
Ultrasonic OurModuleUp(TRIG_PIN, ECHO_PIN);
//Определяем второй датчик
Ultrasonic OurModuleDown(TRIG2_PIN, ECHO2_PIN);
// pins 0, 1 used by Serial
const unsigned char DataPin = 6;
const unsigned char clockPin = 7;
// задержка между ступеньками
const long lightSpacing = 280;
//задержка свечения всей лестницы
const long lightHold = 10000;
//задержка выстрела сенсоров
const long pingReadDelay = 50;
// Диапазон при котором сработает сенсор
const float minBottomIn = 33.0f;
const float minTopIn = minBottomIn;
LightuinoSink sinks(clockPin, DataPin, 100, 4);
boolean bClimbStarted = false;
boolean bDescentStarted = false;
int val;
void setup() {
  pinMode(DataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
void loop() {
   val = analogRead(0);
   //Проверяем освещенность в помещении
   if (val>=1020){
 UltrasonicDownFire();//Выстрел нижнего датчика
  if(bClimbStarted) {
    bClimbStarted = false;
    bDescentStarted = false;
  else {
    // Выстрел верхнего датчика
    if(bDescentStarted) {
      bClimbStarted = false;
      bDescentStarted = false;
//Обработка верхнего датчика
void UltrasonicUpFire() {
if((OurModuleUp.Ranging(INC) < minTopIn) && (OurModuleUp.Ranging(INC) > 0))
Serial.println("Top sensor tripped.");
bDescentStarted = true;
//Обработка нижнего датчика]
void UltrasonicDownFire() {
    if((OurModuleDown.Ranging(INC) < minTopIn) && (OurModuleDown.Ranging(INC) > 0)) {
      Serial.println("Bottom sensor tripped.");
      bClimbStarted = true;
void climbLightSequence(){
void LedsOnDown(){
   byte ledState[9];
  for (int j=0;j=0;k--)
  for (int j=8;j>=1;j--)
   ledState[k] = (ledState[k] >> 1) + 128;
  for (int k=1;k>=0;k--)
  for (int j=8;j>=1;j--)
    ledState[k] = (ledState[k] >> 1);
void descentLightSequence(){
void LedsOnUp(){
  byte ledState[9];
  for (int j=0;j    ledState[j] = B00000000;
  for (int k=0;k  {
  for (int j=0;j  {
    ledState[k]=(ledState[k] << 1) + 1;
  }    }
  for (int k=0;k  {
  for (int j=0;j  {
    ledState[k]=(ledState[k] << 1);


A little bit about the installation

Since I have the simplest wooden staircase (without a landing board), the mounting of LED strips was carried out from the end of each step.


 The cable channel runs along the entire length with the wires laid and glued to liquid nails. LED strips initially have a sticky side, they stick perfectly on the tree.


 Sensors were installed at the beginning of each first step at the top and bottom of the stairs. As a fastener, I used ordinary flush-mounted backing plates.


 A dead battery was thrown out of the case of the power supply unit for the alarm; our controller easily fitted into its place.

The lid is in place. Place the controller under the landing.


In fact, the video does not reflect the real picture. The staircase is lit much more beautiful and brighter.

Read more →

🌟 Writing in the air with LEDs

Daniil Zhuk

Everyone probably knows about the effect of the resulting inscription or pattern when the bar is quickly moved, sometimes a disc with a strip of LEDs that light up in a specially synchronized manner. The effect is called persistence. The effect itself is based on the inertia of the human eye. In order for such an effect to occur, the LEDs must light up at certain points in time so that they shine at fixed points in space when moving left-right.

In the design, which will be discussed, the author used an accelerometer on a circuit board with an LED strip and Arduino Diecimila for control. Power is supplied via USB, but you can connect and stand-alone.


Installation was made on a breadboard. The LED strip, direct connectors for connection to the Arduino board and the edge connector for the accelerometer were mounted. The board connects to the Arduino as a standard expansion card.

The small green board is a three-axis accelerometer, from which the value is taken through the analog inputs of the Arduino. Depending on the acceleration, the accelerometer changes the voltage at its outputs.


// Display goes on PORTD
// GS1 on 10 Sensitivity Selection pins
// GS2 on 11 +- 4g selected here
// SLEEP on 12 and active LOW

int GS1 = 10;
int GS2 = 11;
int SLEEP = 12;

int Y=0; // Temp
int p=0; //Temp

// Tells the microcontroller how to write letters. Little Kid.
// Taken from Sparkfun Library
int text_array[475] = {
0x00,0x00,0x00,0x00,0x00,/*space*/ // is 32 in ASCII
0x00,0x00,0x00,0x00,0x00,/*this should be / */
0x04,0x02,0xFF,0x02,0x04,/*|, arrow*/

// Displays the text
void display(char c)
int i = (c - 32)*5;
for ( int temp = i; temp < i + 5; temp++ ) {
PORTD = text_array[temp]; delayMicroseconds(500);
PORTD = 0x00; delay(3);
PORTD = 0x00; delay(3);

void setup()
pinMode(0,OUTPUT); // Set display as OUTPUT

digitalWrite(GS1,HIGH); // Sensitivity Select
digitalWrite(SLEEP,HIGH); // Don't let the Accelerometer sleep !!!

void loop()
Y = analogRead(1); // Read the sensor...
if ( Y > 650)
if(p=2) // Take alternate acceleration...
delay(60); // Wait a moment before starting

display('P'); // Paaaaraaammm...
display(' ');

Now it remains to connect the assembly to the computer and swing it.

Read more →