Running line on Arduino + control from the smartphone
Foreword
Every year on the street, in transitions, more and more advertising LED panels appear in the stores, on which the text runs up and down, and left and right, and all sorts of colorful pictures are displayed. All this by itself attracts the attention of passers-by and me as well. And often I wondered how this was done and whether something like this could be repeated at home. And just this semester, we had scheduled course work on circuit design, and one of the suggested topics was “Electronic running line”. I thought: “What the hell is not joking? I'll try.
Search for necessary materials and first steps
Previously, I somehow tried to mess with the LEDs, more precisely with the LED tape, but it was a simple light-music system using a single transistor. And here you need to somehow make the LED matrix, and store the text somewhere, and somehow display it. At the "crumbling" just do not do that, at least with my experience.
My light music:
')
Heard what you can do on the Arduino platform. I used to hear that there is such a cool programmable board that this project was a start-up that collected a considerable amount of money, but did not go into details. And then I had to. I watched several videos with examples of projects implemented on Arduino, I liked it, I bought it.
In my work, Arduino Uno R3 was used, but not the original, but a copy. As I read, there is not much difference between the copy and the original. Arduino board has 14 digital I / O, 6 analog, external power inputs, outputs +5 V, +3.3 V, GND. Connects to the computer via USB. For programming the microcontroller uses its own IDE, which is distributed free of charge on the official website of the Arduino.
With Arduino it is clear, now we need to decide how to make the LED matrix itself. Initially, an article was chosen as the basis for developing the project, in which it was proposed to use ready-made modules with LED arrays and shift registers. The scheme is shown in Figure 1. The use of ready-made modules, namely the MAX7219, would greatly simplify development, since it would be necessary to only properly connect everything and write a program for correct operation and output of information.
However, there were difficulties in finding this module in our country, so it was decided to look for another way of implementation. And somehow it would just be completely. Therefore, I decided that the matrix itself should be made on LEDs, since there is enough information on the Internet how to do this.
Development
The size of the matrix was chosen 8x10. It was originally planned to use the shift register 74HC595, which comes in a set with Arduino, to select the LED matrix column, and it has eight outputs. Here everyone would be responsible for a particular column. However, in the process of soldering, the leg of the register, which is responsible for the output of Q0, was accidentally damaged, so it had to be abandoned. In this scheme, a register in essence could only reduce the number of Arduino outputs used to control the matrix. When using it, only three outputs would be involved, and so the 8th had to be sacrificed (from 2 to 9). Fortunately, there are enough of them.
Register scheme:
To select the row of the matrix, a decimal counter with a decoder K176IE8 was used. The choice fell on this chip because of its popularity, and also because it has 10 outputs, just to control the 10th row of the matrix. The counter is controlled using an Arduino microcontroller via the reset, count, and 5 V output inputs.
The outputs of the counter are connected to the transistor unit to control the LED matrix. Connection will be considered in the block of transistors.
Counter scheme:
As a result, the functional diagram is as follows:
Block transistors
To control the LEDs, in addition to the signal supplied to the anodes from 2 to 9 ports of the Arduino, you must also apply voltage to the cathodes of the LEDs. This is done using a block of transistors.
All cathodes of the LEDs of each row are interconnected and connected to the collectors of 10 transistors. The emitters of the transistors are connected to the "ground", and the signals from the meter outputs come to the base.
This project uses bipolar npn transistors of type 2N3904. Since each transistor is connected to its own row of the matrix, in total, 10 of them are used in the circuit. The choice fell on this type of transistors because of their popularity, as well as compliance with the conditions of the developed scheme. This transistor is used in low voltage circuits. General view and UGO of this transistor:
Now you can describe how the LED lights up. From a specific port Arduino signal is sent to the anode of the LED. At the same time, a signal from the specific output is sent to the base of the emitter. And from the collector of the transistor goes voltage to the cathodes of the LEDs. Since in the matrix the anodes of the LEDs of the adjacent rows are connected in series, and the cathodes of the LEDs of the adjacent columns are connected in series, at the same time several LEDs of the matrix light up.
An important point! Arduino produces about 5 V at the output, therefore, to connect the anodes of the LEDs to the Arduino, you need to use resistors with a nominal value of 220 ohms, and to connect the transistor base to the meter outputs - with a nominal value of 1 kΩ. It is easy to find these resistors, especially since they are in the Arduino starter kit.
From thought to action, or from scheme to implementation
As a result, the following device was soldered.
Software part
Now the whole thing had to be connected to Arduino. The code itself was written in C. First of all, you need to initialize the ports used on the Arduino board. This is done in the setup () function as follows:
voidsetup(){ int i; for(i = 2; i < 10; i++) pinMode(i,OUTPUT); pinMode(clock,OUTPUT); pinMode(reset,OUTPUT); digitalWrite(reset,HIGH); delayMicroseconds(5); digitalWrite(reset,LOW); }
clock and reset are ports 11 and 10 of the Arduino, respectively.
The first thing is an indication that ports 2 through 9 are used as holiday. This is done in a loop using the pinMode method (i, OUTPUT), where i is the port number, OUTPUT is a flag indicating that this port is output.
Further, the clock and reset ports are initialized in the same way. Using the digitalWrite (reset, HIGH) function, a high voltage level is applied to the reset port, thereby resetting the counter. After 5 ms delay (delayMicroseconds (5)), a low voltage level is applied to the reset port.
After the ports are initialized, it is necessary to develop an algorithm to turn on the LEDs to output test information and simulate their movement, i.e. make the algorithm a running line.
For this, a separate function display_symbol (int loops) was created, which takes as its argument a delay value to simulate text movement. It was established experimentally that all information is better perceived if the delay value is in the range from 15 to 25.
Consider the internal implementation of the display_symbol (int loops) function.
First you see four nested loops. The outermost loop passes through all elements of the byte array, i.e. by output characters. Byte array and its dimension is set by the developer manually looks like the following:
byte symbols[numsymbols][10]={C, X, E, M, O, T, E, X, H, I_RUS, K, A }; constint numsymbols = 13;
Each character is decomposed into 10 bytes, which corresponds to the number of lines, and each byte is known to consist of 8 bits. Each bit is responsible for a specific LED on the circuit. An example of a broken-down character:
For example, 0 and 9 bytes look like B00000000, which means that LEDs 1 and 10 will not light up. This is done for easy reading by the user. And here, for example, the 1st byte with the value B01000010 indicates that the second line for this symbol should light up 2 and 7 LEDs. Thus from all these bytes the character of the letter "I" is built.
Here is what happened as a result:
And where is the promised control from a smartphone?
In principle, I was satisfied with the result, after all, for the first time, I soldered so much and everything worked right away. But I wanted more, and I thought to add control from an Android smartphone via Bluetooth. For Arduino there is a ready module HC-06. The scheme of its connection to the Arduino is as follows:
Details of the connection to the Arduino and connections to the smartphone are described in this article: Bluetooth module HC-06 connection to the Arduino.Connection with telephone and computer In accordance with this code has been changed. And I decided to add accelerated scrolling of the text, inverse ignition of the LEDs and scrolling of the text with flickering. Links to code for Android and Arduino will be lower. The result was such a thing:
Conclusion
First, with regard to developed coursework. The main advantage of the developed device is its versatility. Thanks to the use of the Arduino programmable board, the project can be expanded using various sensors and writing the appropriate firmware. As a result, in addition to the running line functionality, you can add the functionality for displaying weather conditions using, respectively, temperature, humidity and atmospheric pressure sensors. If you add any sound sensor, you can modify the scheme to the musical equalizer.
But the general conclusions are that the Arduino is a really cool thing, with which you can make a lot of useful and cool stuff at home that people who have dedicated to electronics for more than one year could have done before. Moreover, there are many examples of various devices on the Arduino on the Internet in the public domain. There are even many books on Arduino, one of which I would definitely recommend to consider as a guide for beginners and advanced developers: Arduino CookBook .