Display numbers by LED

Hello! The Internet of Things (IoT) is already heard by every grandparents. In the flock, greenhouse or garage, for sure, there is already a smart socket. Let's get down to business. It is necessary to know the humidity and temperature, but for some reason the display is not possible to use.



List of reasons:



In this case, there is an excellent reason to use the color approach to displaying information. Everything would be fine, but the primary colors are completely worthless - some seven (from the rainbow). Can you distinguish between blue and blue or yellow from orange? If you can, then grandmother is unlikely. What to do? Remove such weird colors! Leave: Red, Yellow, Green, Blue, Pheasant Violet and White (unexpectedly, yes?). How much did it work? 6. And there are 10 digits, and even a minus for negative numbers, a floating point and a separator. We will be smart and make a flasher! Violet - it will be 5, and six it will be 5 + 1, and 1 will be Red. Just fit. Huh! Table 1 shows the colors for the corresponding characters.


Table 1


Digit (or symbol)Colour
Zeroflashing violet
OneRED on
Twoburns YELLOW
Threeburns GREEN
Fourburns BLUE
FiveLIGHT PURPLE
Sixflashing PURPLE / RED
Sevenflashing PURPLE / YELLOW
Eightflashing PURPLE / GREEN
NineFlashing PURPLE / BLUE
Minus (-)blinking WHITE / RED
Dot (.)blinking WHITE
End of line (\ n)burns WHITE

In order to display the number, it is necessary, of course, to download and connect the library. Then declare the user callback function void callback (int, int, int) R, G, B - channels (from 0 to 255), which will access the hardware (light the LED). Call the lightf function, where the first argument will be a pointer to this same callback function, then a line with a format that is completely analogous to printf and any number of arguments. Remember to use the newline character \ n after each qualifier in the format string.


At my fingertips lies the M5Stack FIRE Base Unit with built-in Neopixel panels, for testing, as nothing is better. A video demonstrating a sketch displaying the Pi number up to 6 decimal places can be seen here .


I didn’t just say that IoT at the very beginning. Seriously, this approach is perfect for displaying a PIN code for pairing devices, etc.


Love and do not forget your old people. Thanks for attention!


Link to the library here



Source: https://habr.com/ru/post/476858/


All Articles