How we designed the electronic jewelery platform
The idea to cross electronics and jewelry is very old. Therefore, when we remembered it, the search gave a large number of works on this subject. True, often, electronic jewelery meant jewelry from electronics — board pieces dressed in epoxy, elements, and microchip pendants. We wanted to make LED decorations. Not the same as in Chinese toys that sell at every corner, because everything is rather uninteresting in them - there are several blinking programs that can be switched by a button, but something more complicated and more interesting. For example, running lights that react to ambient lighting, burning brighter in the dark and dim in the light. Or flickering to the beat of the surrounding music. Or changing color depending on the temperature around. Or showing the heart rate of the carrier. In other words, we wanted some kind of active reaction.

Warning: this article was written primarily for non-technical professionals, so it has some simplifications that may cause engineers to disapprove. Feel free to express them.
Thus, the requirements for the electronic part:
Having fixed these requirements, we began to think seriously. Like any technical problem, this one had a lot of solutions.
For example, we could take the standard constructor like LiliPad or Adafruit GEMMAcreated just for this purpose. If you look at examples of GEMMA, then there you can see a large number of similar projects with LEDs, there are even earrings. Unfortunately, the designer is very well suited at the prototype stage, when the device needs to be assembled from dirt and sticks to check if it works at all, but, alas, it is absolutely not suitable for any small series - additional connectors, connections and the whole design interfere . Well, the cost of the designer and parts to it (and we remember that we also need LEDs and sensors) also plays unpleasantly on the cost of the final product not in the most interesting direction for the buyer. So designers are a good option, but generating a large number of questions.
The alternative is to develop the electronic part entirely and independently. This way is both simpler (since we can leave only what we need) and difficult (because the creation of a programmable device even for our seemingly simple task carries a lot of pitfalls and compromise solutions). Of course, seeing such a wonderful opportunity to deflate some parts of the body, we could not pass by.
Here, probably, it is worth making a small excursion into the manufacture of electronics and how it happens.
So, we have an idea and requirements. It remains to embody them "in the gland."
Reflections on the question gave rise to a large number of doubts:
So, we dig in the search, sort through the combinations and as a result we get the following solution that satisfies us:
Once we have decided on the components, download the documentation for the controller and the LEDs and dive into the study. The nuances come up - the LEDs are connected in series, “train” and are controlled by one wire, to which the controller must form a special signal, roughly speaking - to send a specific sequence of numbers, each of which will mean the intensity with which to light each of the built-in LEDs (and we Remember that in one case we have three of them - red, green and blue). Those. we need to consistently send the brightness of red, green and blue for the first LED, then for the second, then for the third and so on, depending on how many of them we have on in series. If you've seen LED tapes in building stores, iridescent with all the rays of a rainbow, then you should know
In addition to controlling these LEDs, noise protection is required, which will require one capacitor per LED. In addition, the same noise capacitor is required for the microcontroller.
Further, the LEDs, even in such a compact version, are still greedy for power. Therefore, their greed should be limited, and we have one limiter - resistance. Those. Each LED requires an additional current-limiting resistor. It's funny that in the process of product development it turned out that these resistors do not help much, how much damage - when there are more than four LEDs, there is a lack of current and I had to change them to zero ohms, i.e. banal jumpers to LEDs work correctly. In subsequent versions of the scheme, we completely removed them.
The photoresistor also required an additional resistor playing the role of a voltage divider. Examples of schemes for connection can be found fully, if you type in a search engine “arduino photoresistor connection”.
We should also say separately for programming the microcontroller - in order to fill in the firmware (program code in binary form) in Attiny85, a special device - a “programmer” is required. Fortunately, it is assembled on the basis of the Arduino electronic designer (in which his elder brother is also Atmel's microcontroller, but more seriously), which can be bought at any electronic store or in China for little money.
And finally, the switch - we do not want the user to constantly insert and remove the battery.
However, despite all of the above, the basic scheme turned out to be simple compared to most household devices (most likely, your thermotube is more complicated in electronics than our scheme):

As a result, we got a device that has dimensions slightly larger than a conventional button-type battery. Actually, the battery and the switch are placed on one side, the LEDs, the microcontroller and the light sensor on the other. Since the LEDs can also affect the light sensor located nearby (let's say, light it up so that it will assume that the circle is light, although in fact there may still be darkness), it was decided to mount it with the ability to bend in a plane perpendicular to the direction glow.
As a result of the layout, we have a fairly simple printed circuit board. Before wiring, we checked the circuit and it turned out to be efficient, though with one reservation - we checked it on a constant power source, and not on a battery, therefore fears that such a small battery would not last long enough until we soldered the first devices.
So, the scheme is done, the board is divorced. And then the first compromise is that Attiny85 microcontrollers are available in two types of enclosures - DIP (these are classic microcircuits with pin legs, which you probably saw at the dawn of electronic distribution and simple devices) and SO (these are planar microcircuits, small and compact, do not require additional holes for soldering and mounted on top of the board by soldering). At the time of designing, our supplier had a more expensive SO-version component and, most importantly, it was not available. Therefore, we took the DIP version, but with the expectation that we will first program it, and then carefully bite off the legs and solder it as SO, directly to the board. This made an additional technological risk - to change the firmware in this version after soldering the microcontroller to the board would not be a very trivial task,

We ordered the boards in China, this process is fine-tuned there, and we started collecting components. LEDs and battery holders were also ordered in China, they either did not exist on the local market, or they were worth indecent money. The rest is bought in the nearest electronic supermarket. Microcontrollers could also be ordered in China, but a large number of negative responses and their own sad experience (when the components sent out did not provide enough good quality) kept us from taking this step. Therefore, by the time we received the finished printed circuit boards, the entire BoM was in our hands. There is even time left to slowly solder the programmer for microcontrollers.

After receiving the boards, we soldered one test device. Since the program for the microcontroller was postponed until the finished device was received (and it was right, I will tell you a little later), we did not solder the microcontroller “for good”, but made a transitional platform into which the microcircuit can be plugged like a bulb into a cartridge. As expected, the device did not work. Looking closely at the device (for a couple of hours), we found a mistake - the LEDs were soldered incorrectly. The fact is that when mounting chips and elements with a large number of legs it is very important not to confuse these legs and put the element correctly. To do this, the engineers on the markings on the printed circuit board use a key - an image of a point, which must coincide with the same one on the chip's case. As a result, the process of soldering such an element looks like this - we combine the keys, solder one leg, solder all the others. To confuse the key is usually fraught with negative consequences - the author of these lines somehow stuffed the microcontroller into the programmer from the wrong side - after five seconds the air smelled fried, and the finger that touched the chip got a neat burn according to the shape of the case. Fortunately, no one was hurt anymore and after cooling the microcontroller also remained working.
So, in the design of our board, we applied a self-made description for LEDs (three-millimeter SK6812s are rarely found than WS2812) and they safely made a mistake with the key. As a result, when mounting the LED key must be located on the other side relative to the key marked on the board. The test board went safely to the scrap.
The second test sample was assembled taking into account this error. Now we were sure that our scheme was operational and began to program the firmware.
It looked like this:

I note that sometimes during the day this operation had to be repeated several dozen times. It was possible to solder the programmer directly to the chip on the board, but, as you remember, we are not looking for easy ways.
At the programming stage, too many interesting things came to light.
It all started with the fact that none of the standard libraries work with managed LEDs did not work. The reason was not in one place, but in two. Firstly, the time intervals for coding control signals were intended for other types of LEDs and did not coincide with the ones indicated in our documentation. Secondly, it turned out that in the case of battery power, the microcontroller operates at a lower frequency and, by default, can reduce it even more to save energy (which it does when on a battery), which again leads to a change in the time intervals for controlling the LEDs. A pair of clocks with an oscilloscope helped adjust the library to the required intervals, and half an hour and a few experiments allowed us to find a command that prohibits the microcontroller from changing the frequency of operation.
The second surprise was the light sensor. After programming it, we couldn’t understand for a long time why there was no reaction to closing it with a finger (i.e., completely darkening) from the word “absolutely”. The answer came after a few days of intently peering into examples of working with such sensors. It turned out that when setting up the analog port to which the sensor was to be connected, it was necessary to use one numbering, and when reading readings, another one (yes, I also remembered the anecdote “Wow, an error in one digit, but who cares!”) . After this awareness, everything worked as it should. The firmware was written.
Since we were sent not one, and not two printed circuit boards, but ten at once (one, as we remember, was disposed of), we soldered all the others to the joy.
It turned out that the law of large numbers works in small batches - two out of ten boards showed a manufacturing defect - our Chinese colleagues did not build the electrical connection between the front and back layers of the board well enough, as a result, nothing worked due to lack of power. Fortunately, this can be easily eliminated by soldering the vias with the conductor.
The devices are assembled, tested and transferred for further processing to give the appearance of the finished decoration. In fact, we spent no more than a week on the whole development, but due to distractions to other tasks and expectations (free time, components, printed circuit boards) the whole process was spread over a half-year time interval.
If anyone is interested, the source code and project materials are laid out on Github.
The story does not end there. After the first instructive experience, we made several versions of the board.
The second version was in two versions - with six LEDs in a circle and four (one in the center) and different in that here we used the SO-package of the chip. But even there it was not without excesses - when wiring the board because of the confusion in the names, the wrong contact area was chosen and as a result, the mounting feet of the chip had to be pressed under the case. In addition, they brought out the contacts for the firmware and the three "power-signal-ground" on separate platforms, in order to be able to add more LEDs as a remote element.

In addition, another unpleasant flaw was revealed - the master very much asked to make the board perfectly round (in our version it looked more like a rectangle with rounded corners). They did it, at the same time checking the Chinese industry for the production of boards thinner than a millimeter in thickness. The result was completely satisfactory - replacing the holders with those designed for CR2016 batteries, we got an even more lekhovesnuyu platform from which you can already make, for example, earrings.
For the firmware of these devices, a programmer a la “collective farm” was used on pogo pins. As it turned out, the firmware download procedure was still non-trivial - it was necessary to press the board tightly enough to the pins, which was not immediately possible the first time.

The apotheosis of the development of this branch of the platform was the third and latest version. In it, the contacts for the firmware were brought to a separate flexible cable, an additional fee was ordered for the programmer. At this iteration, we appreciated Seeedstudio's PCBA service, which made printed circuit boards for us — the Chinese industry brought the boards with most of the elements mounted, we soldered the connector for the programmer, the battery holder, the photoresistor and the LEDs - they were not (except for the photoresistor) components available for installation.
The result looks like this:


In general, the project was interesting. As it turned out, even seemingly simple things can conceal very complex nuances inside, which was clearly shown.

Warning: this article was written primarily for non-technical professionals, so it has some simplifications that may cause engineers to disapprove. Feel free to express them.
Thus, the requirements for the electronic part:
- there should be several controlled LEDs (managed - this means that we can not just turn on and off their glow, but also control their brightness and, importantly, color);
- You must have at least one sensor - a light sensor, a temperature sensor, or a microphone. Pulse sensors have been set aside so far - they require a direct approach to the body (therefore, your fitness bracelet is useless in this regard if you wear it over a shirt);
- control must be programmable. This means that at any moment we can change the logic of controlling the LEDs to a more appropriate one for the entourage of the finished decoration, for example, if cold colors prevail in the decoration, then make the glow appropriate;
- the device should be compact and light, because heavy pieces severely limit the possibility of their use;
- the circuit should be powered by batteries or from batteries that can be bought at any corner for the convenience of the consumer.
Having fixed these requirements, we began to think seriously. Like any technical problem, this one had a lot of solutions.
For example, we could take the standard constructor like LiliPad or Adafruit GEMMAcreated just for this purpose. If you look at examples of GEMMA, then there you can see a large number of similar projects with LEDs, there are even earrings. Unfortunately, the designer is very well suited at the prototype stage, when the device needs to be assembled from dirt and sticks to check if it works at all, but, alas, it is absolutely not suitable for any small series - additional connectors, connections and the whole design interfere . Well, the cost of the designer and parts to it (and we remember that we also need LEDs and sensors) also plays unpleasantly on the cost of the final product not in the most interesting direction for the buyer. So designers are a good option, but generating a large number of questions.
The alternative is to develop the electronic part entirely and independently. This way is both simpler (since we can leave only what we need) and difficult (because the creation of a programmable device even for our seemingly simple task carries a lot of pitfalls and compromise solutions). Of course, seeing such a wonderful opportunity to deflate some parts of the body, we could not pass by.
Here, probably, it is worth making a small excursion into the manufacture of electronics and how it happens.
How electronics is made on the fingers
Сначала формируется идея и требования к устройству (ну, то, что мы уже сделали). Затем эти требования обсуждаются со специалистами по электронике и совместными усилиями уточняются — проект обрастает деталями и нюансами.
Рисуется принципиальная схема устройства — то, как электронные компоненты должны соединяться друг с другом, чтобы работать вместе. Схема проверяется на практике — из подручных средств и на проводках собирается первое устройство. Если оно заработает, то, значит, исходная схема была правильная и можно двигаться дальше.
После того, как у нас есть проверенная принципиальная схема устройства, начинается самое интересное — разводка печатной платы, т.е. такого кусочка текстолита с дорожками, на который напаиваются электронные компоненты. Можно, конечно, делать все на проводках, но это будет медленно, скучно и крайне ненадежно. Кроме того, современные технологии достигли такого распространения, что изготовить печатную плату с промышленным качеством можно за очень небольшие деньги. Впрочем, мы это еще увидим. Проектирование печатной платы состоит в том, чтобы показать, как мы будем располагать элементы и как будут они между собой взаимосвязаны. Или, проще говоря, нам надо перерисовать принципиальную схему красиво и с учетом реальных физических размеров деталей.
Просто спроектировать печатную плату (на профессиональном жаргоне — “развести”) недостаточно, еще надо подготовить ее к производству, т.е. сформировать правильный набор документов, который включает в себя внешний вид результата, схему проводящих дорожек, схему сверления и металлизации. Обычно даже у опытных инженеров это получается не сразу, особенно в случае, когда устройство непростое. Эти файлы (в формате Gerber) передаются в производство. Пока печатная плата выпускается, происходит закупка элементов, которые будут припаиваться на нее. На профессиональном языке список таких элементов называется BoM (от английского Bill of Materials — список компонентов).
После получения печатной платы и закупки всех необходимых компонентов происходит монтаж элементов на плату, который может быть ручной (обычно применяется для небольших тиражей до тысячи экземпляров) или автоматический (специальными станками для больших партий). Ручной монтаж выглядит в виде инженера с паяльником, который просто припаивает элементы на плату согласно предоставленной ему схеме.
После завершения монтажа устройство программируется (если оно содержит микросхемы, которые это допускают) и тестируется, т.е. проверяется его работоспособность и устойчивость к различного рода внешним воздействиям. Если устройство прошло все тесты, то его признают работоспособным и передают дальше на корпусировку (т.е. помещение в коробочку) или на дальнейшую обработку (как в нашем случае). Если нет — производят диагностику причин, чинят, повторно тестируют и либо бракуют окончательно, либо передают дальше.
В общем, процесс производства электроники не самый простой и тривиальный. Если вы твердо вознамерились сходить этим путем, то крайне рекомендуем заручится поддержкой квалифицированных инженеров по данному направлению, желательно, с опытом в данном деле.
Рисуется принципиальная схема устройства — то, как электронные компоненты должны соединяться друг с другом, чтобы работать вместе. Схема проверяется на практике — из подручных средств и на проводках собирается первое устройство. Если оно заработает, то, значит, исходная схема была правильная и можно двигаться дальше.
После того, как у нас есть проверенная принципиальная схема устройства, начинается самое интересное — разводка печатной платы, т.е. такого кусочка текстолита с дорожками, на который напаиваются электронные компоненты. Можно, конечно, делать все на проводках, но это будет медленно, скучно и крайне ненадежно. Кроме того, современные технологии достигли такого распространения, что изготовить печатную плату с промышленным качеством можно за очень небольшие деньги. Впрочем, мы это еще увидим. Проектирование печатной платы состоит в том, чтобы показать, как мы будем располагать элементы и как будут они между собой взаимосвязаны. Или, проще говоря, нам надо перерисовать принципиальную схему красиво и с учетом реальных физических размеров деталей.
Просто спроектировать печатную плату (на профессиональном жаргоне — “развести”) недостаточно, еще надо подготовить ее к производству, т.е. сформировать правильный набор документов, который включает в себя внешний вид результата, схему проводящих дорожек, схему сверления и металлизации. Обычно даже у опытных инженеров это получается не сразу, особенно в случае, когда устройство непростое. Эти файлы (в формате Gerber) передаются в производство. Пока печатная плата выпускается, происходит закупка элементов, которые будут припаиваться на нее. На профессиональном языке список таких элементов называется BoM (от английского Bill of Materials — список компонентов).
После получения печатной платы и закупки всех необходимых компонентов происходит монтаж элементов на плату, который может быть ручной (обычно применяется для небольших тиражей до тысячи экземпляров) или автоматический (специальными станками для больших партий). Ручной монтаж выглядит в виде инженера с паяльником, который просто припаивает элементы на плату согласно предоставленной ему схеме.
После завершения монтажа устройство программируется (если оно содержит микросхемы, которые это допускают) и тестируется, т.е. проверяется его работоспособность и устойчивость к различного рода внешним воздействиям. Если устройство прошло все тесты, то его признают работоспособным и передают дальше на корпусировку (т.е. помещение в коробочку) или на дальнейшую обработку (как в нашем случае). Если нет — производят диагностику причин, чинят, повторно тестируют и либо бракуют окончательно, либо передают дальше.
В общем, процесс производства электроники не самый простой и тривиальный. Если вы твердо вознамерились сходить этим путем, то крайне рекомендуем заручится поддержкой квалифицированных инженеров по данному направлению, желательно, с опытом в данном деле.
So, we have an idea and requirements. It remains to embody them "in the gland."
Reflections on the question gave rise to a large number of doubts:
- LEDs are quite “voracious” elements because they are sources of light. The controlled LEDs are “hungry” triple, because in essence they are three different LEDs combined in one package (according to the color components - red, green and blue). And, as we remember, we wanted a compact device, i.e. for a large battery, we simply have no space;
- battery and power - the bottleneck of the project as a whole. Let me remind you that according to the plan, in addition to the LEDs, there should be sensors and a glow control circuit that also consume electrical energy. And the buyer is unlikely to be satisfied if his decoration will work for a few minutes, and then it will require a change of batteries;
- the device must be programmable - i.e. we should be able to control the glow at the program level. Which automatically requires a microprocessor device, called a microcontroller. This is a chip to which you can connect both LEDs and sensors. Inside it is a simple microprocessor and memory that allows you to write into it a program to control all connected devices. And this microcontroller, as follows from the preceding paragraphs, must consume very little electrical energy in order not to condemn the user to a constant change of batteries;
- since there are a great many different sensors, it was decided to focus only on one of them - the light sensor. A photoresistor is used as such a sensor, which operates according to this principle - if light is incident on it, then its resistance decreases, if it is in the dark - it increases. This is a simple sensor, connecting which to the input of the microcontroller, we get an instrument for measuring the illumination. Looking ahead, I will say that there are temperature and sound sensors that work according to the same principles and can replace the photoresistor without making significant changes to the final circuit;
- the printed circuit board on which the installation should be made should be round or with beveled corners - again, for aesthetic reasons, there are not so many rectangular and square decorations.
So, we dig in the search, sort through the combinations and as a result we get the following solution that satisfies us:
- the power is a standard CR2032 battery, also known as a “tablet,” the size of a ten-ruble coin. It provides 3 Volts, is stored for a long time, works in a wide range of temperatures, is cheap, is sold in any supermarket. The holder for such a battery is simple to the horror and is also very inexpensive;
- microcontroller - Atmel Attiny85, compact, low power, easily programmable, cheap. An additional advantage is that this chip has an analog input (that is, you can connect a sensor without additional circuits) and a small number of legs (which is a very big plus in our quest for compactness);
- LEDs - SK6812 mini, which are 3.5 mm by 3.5 mm. It seemed to us that the usual five-millimeter LEDs would be very overall and very voracious for this scheme. In addition, they are usually fed with a voltage of 5 volts, and our battery provides only 3 volts, i.e. for work it would be necessary to use a converter, which was not desirable;
- The photoresistor is a light sensor - the traditional one, which is used in cameras and intercoms to determine the onset of night.
Once we have decided on the components, download the documentation for the controller and the LEDs and dive into the study. The nuances come up - the LEDs are connected in series, “train” and are controlled by one wire, to which the controller must form a special signal, roughly speaking - to send a specific sequence of numbers, each of which will mean the intensity with which to light each of the built-in LEDs (and we Remember that in one case we have three of them - red, green and blue). Those. we need to consistently send the brightness of red, green and blue for the first LED, then for the second, then for the third and so on, depending on how many of them we have on in series. If you've seen LED tapes in building stores, iridescent with all the rays of a rainbow, then you should know
In addition to controlling these LEDs, noise protection is required, which will require one capacitor per LED. In addition, the same noise capacitor is required for the microcontroller.
Further, the LEDs, even in such a compact version, are still greedy for power. Therefore, their greed should be limited, and we have one limiter - resistance. Those. Each LED requires an additional current-limiting resistor. It's funny that in the process of product development it turned out that these resistors do not help much, how much damage - when there are more than four LEDs, there is a lack of current and I had to change them to zero ohms, i.e. banal jumpers to LEDs work correctly. In subsequent versions of the scheme, we completely removed them.
The photoresistor also required an additional resistor playing the role of a voltage divider. Examples of schemes for connection can be found fully, if you type in a search engine “arduino photoresistor connection”.
We should also say separately for programming the microcontroller - in order to fill in the firmware (program code in binary form) in Attiny85, a special device - a “programmer” is required. Fortunately, it is assembled on the basis of the Arduino electronic designer (in which his elder brother is also Atmel's microcontroller, but more seriously), which can be bought at any electronic store or in China for little money.
And finally, the switch - we do not want the user to constantly insert and remove the battery.
However, despite all of the above, the basic scheme turned out to be simple compared to most household devices (most likely, your thermotube is more complicated in electronics than our scheme):

As a result, we got a device that has dimensions slightly larger than a conventional button-type battery. Actually, the battery and the switch are placed on one side, the LEDs, the microcontroller and the light sensor on the other. Since the LEDs can also affect the light sensor located nearby (let's say, light it up so that it will assume that the circle is light, although in fact there may still be darkness), it was decided to mount it with the ability to bend in a plane perpendicular to the direction glow.
As a result of the layout, we have a fairly simple printed circuit board. Before wiring, we checked the circuit and it turned out to be efficient, though with one reservation - we checked it on a constant power source, and not on a battery, therefore fears that such a small battery would not last long enough until we soldered the first devices.
So, the scheme is done, the board is divorced. And then the first compromise is that Attiny85 microcontrollers are available in two types of enclosures - DIP (these are classic microcircuits with pin legs, which you probably saw at the dawn of electronic distribution and simple devices) and SO (these are planar microcircuits, small and compact, do not require additional holes for soldering and mounted on top of the board by soldering). At the time of designing, our supplier had a more expensive SO-version component and, most importantly, it was not available. Therefore, we took the DIP version, but with the expectation that we will first program it, and then carefully bite off the legs and solder it as SO, directly to the board. This made an additional technological risk - to change the firmware in this version after soldering the microcontroller to the board would not be a very trivial task,

We ordered the boards in China, this process is fine-tuned there, and we started collecting components. LEDs and battery holders were also ordered in China, they either did not exist on the local market, or they were worth indecent money. The rest is bought in the nearest electronic supermarket. Microcontrollers could also be ordered in China, but a large number of negative responses and their own sad experience (when the components sent out did not provide enough good quality) kept us from taking this step. Therefore, by the time we received the finished printed circuit boards, the entire BoM was in our hands. There is even time left to slowly solder the programmer for microcontrollers.

After receiving the boards, we soldered one test device. Since the program for the microcontroller was postponed until the finished device was received (and it was right, I will tell you a little later), we did not solder the microcontroller “for good”, but made a transitional platform into which the microcircuit can be plugged like a bulb into a cartridge. As expected, the device did not work. Looking closely at the device (for a couple of hours), we found a mistake - the LEDs were soldered incorrectly. The fact is that when mounting chips and elements with a large number of legs it is very important not to confuse these legs and put the element correctly. To do this, the engineers on the markings on the printed circuit board use a key - an image of a point, which must coincide with the same one on the chip's case. As a result, the process of soldering such an element looks like this - we combine the keys, solder one leg, solder all the others. To confuse the key is usually fraught with negative consequences - the author of these lines somehow stuffed the microcontroller into the programmer from the wrong side - after five seconds the air smelled fried, and the finger that touched the chip got a neat burn according to the shape of the case. Fortunately, no one was hurt anymore and after cooling the microcontroller also remained working.
So, in the design of our board, we applied a self-made description for LEDs (three-millimeter SK6812s are rarely found than WS2812) and they safely made a mistake with the key. As a result, when mounting the LED key must be located on the other side relative to the key marked on the board. The test board went safely to the scrap.
The second test sample was assembled taking into account this error. Now we were sure that our scheme was operational and began to program the firmware.
It looked like this:
- microcontroller chip inserted into the programmer;
- firmware was poured into it;
- the chip was taken out and inserted into the device;
- power on and performance checked;
- all repeated from the beginning.

I note that sometimes during the day this operation had to be repeated several dozen times. It was possible to solder the programmer directly to the chip on the board, but, as you remember, we are not looking for easy ways.
At the programming stage, too many interesting things came to light.
It all started with the fact that none of the standard libraries work with managed LEDs did not work. The reason was not in one place, but in two. Firstly, the time intervals for coding control signals were intended for other types of LEDs and did not coincide with the ones indicated in our documentation. Secondly, it turned out that in the case of battery power, the microcontroller operates at a lower frequency and, by default, can reduce it even more to save energy (which it does when on a battery), which again leads to a change in the time intervals for controlling the LEDs. A pair of clocks with an oscilloscope helped adjust the library to the required intervals, and half an hour and a few experiments allowed us to find a command that prohibits the microcontroller from changing the frequency of operation.
The second surprise was the light sensor. After programming it, we couldn’t understand for a long time why there was no reaction to closing it with a finger (i.e., completely darkening) from the word “absolutely”. The answer came after a few days of intently peering into examples of working with such sensors. It turned out that when setting up the analog port to which the sensor was to be connected, it was necessary to use one numbering, and when reading readings, another one (yes, I also remembered the anecdote “Wow, an error in one digit, but who cares!”) . After this awareness, everything worked as it should. The firmware was written.
Since we were sent not one, and not two printed circuit boards, but ten at once (one, as we remember, was disposed of), we soldered all the others to the joy.
It turned out that the law of large numbers works in small batches - two out of ten boards showed a manufacturing defect - our Chinese colleagues did not build the electrical connection between the front and back layers of the board well enough, as a result, nothing worked due to lack of power. Fortunately, this can be easily eliminated by soldering the vias with the conductor.
The devices are assembled, tested and transferred for further processing to give the appearance of the finished decoration. In fact, we spent no more than a week on the whole development, but due to distractions to other tasks and expectations (free time, components, printed circuit boards) the whole process was spread over a half-year time interval.
If anyone is interested, the source code and project materials are laid out on Github.
The story does not end there. After the first instructive experience, we made several versions of the board.
The second version was in two versions - with six LEDs in a circle and four (one in the center) and different in that here we used the SO-package of the chip. But even there it was not without excesses - when wiring the board because of the confusion in the names, the wrong contact area was chosen and as a result, the mounting feet of the chip had to be pressed under the case. In addition, they brought out the contacts for the firmware and the three "power-signal-ground" on separate platforms, in order to be able to add more LEDs as a remote element.

In addition, another unpleasant flaw was revealed - the master very much asked to make the board perfectly round (in our version it looked more like a rectangle with rounded corners). They did it, at the same time checking the Chinese industry for the production of boards thinner than a millimeter in thickness. The result was completely satisfactory - replacing the holders with those designed for CR2016 batteries, we got an even more lekhovesnuyu platform from which you can already make, for example, earrings.
For the firmware of these devices, a programmer a la “collective farm” was used on pogo pins. As it turned out, the firmware download procedure was still non-trivial - it was necessary to press the board tightly enough to the pins, which was not immediately possible the first time.

The apotheosis of the development of this branch of the platform was the third and latest version. In it, the contacts for the firmware were brought to a separate flexible cable, an additional fee was ordered for the programmer. At this iteration, we appreciated Seeedstudio's PCBA service, which made printed circuit boards for us — the Chinese industry brought the boards with most of the elements mounted, we soldered the connector for the programmer, the battery holder, the photoresistor and the LEDs - they were not (except for the photoresistor) components available for installation.
The result looks like this:


In general, the project was interesting. As it turned out, even seemingly simple things can conceal very complex nuances inside, which was clearly shown.