Nature's Tips - a cloudy night light
I present my own implementation of the lamp-night lamp in the form of a cloud. The main idea is to make a nightlight with imitations of natural processes and some kind of interactivity. Nature is the best inspirer!
The basis was taken by the cheap ATmega8-16PU microcontroller. The code is written in C without Arduino and implements several light effects with control from the general illumination of space and with sound control.
Details and photos - more
Electronic Details 3r3204.
The circuit, in addition to the microcontroller, has 6 monochrome LEDs, one RGB LED, a light sensor (photoresistor) and a microphone with an amplifier and RF filter.
For a smooth change in the brightness of the LEDs used
. The PWM frequency is 244 Hz at 64 levels, it happens that some people see it. Increasing the frequency does not work - you need more CPU time to work. Therefore, a circuit on a transistor follower with a smoothing capacitor is used to smooth the PWM pulses. The transistor is taken with a large gain, to increase the input resistance and reduce the required capacitance. As a result, 1 microfarad turned out to be quite enough, the pulses are almost completely smoothed. Advantages are cheaper than a DAC and have a large output current. The disadvantage of the scheme is the nonlinear dependence of brightness on the PWM level at low levels (up to 15%).
Micro-Cap 9 [/b] layout.
Smoothing scheme PWM. 4 diodes approximately = 1 white LED according to IVC
Graph of current and voltage on the LED at 56% PWM.
A miniature electret microphone through an amplifier on two transistors with a pulse (RF filter) is connected to the discrete input of the MK, confidently catching harsh sounds - clapping hands.
He drew the board and spread it in 3r371. DipTrace
, made LUT, the details are basically smd. Etching did in the "ferric chloride killer": Hydrogen peroxide + salt + citric acid, it came out the first time, I recommend. 3r373. All amateur ways are written here. 3r3198.
The fee made by LUT
Power made via USB-connector that allows you to connect to any USB-port. Maximum consumption 78 mA.
In previous versions, there was a micro-button on the cable for mode settings, but then it was removed, so as not to reach it, if the cloud is under the ceiling.
There is no USB connection, there is no USB in the MC, and it seems that it is not necessary in the finished product. For debugging, I used the UART controller, the code implements the exchange with the computer, but there it is commonplace
written on the knee .
In the process of soldering
LUT, soldering, writing the program, tests and alterations, fitting timers and coefficients took 3 weeks.
General view of
As a result, implemented 3 modes of illumination and light effects. I tried to make the lava lamp more interesting, but there was also no disco-music music with whistles-perdelki.
3r3r1616. The main 3r3167. - nightlight in the form of a cloud. Different parts of the cloud in a random order smoothly change the brightness, the change period is also random (4 25 seconds), the type of change - exponential smoothing from the task (I can tell more in the comments). It looks as a whole, with a share of imagination, like a play of light in a real cloud when it covers the sun. The maximum level of brightness depends on the level of lighting according to the schedule. I picked up various dependencies, there was an option with a choice of dependencies on the button, but I stopped on one this.
Graph of the brightness of the cloud from the ambient light.
Since during the outer darkness (night) the cloud almost does not glow, and a short-term bright light may be needed (for example, to rise at night), then for this purpose I invented the “Bright Cloud” submode. It turns on with two clapping hands, and a microphone is used here, since the buttons are usually out of reach. The cloud glows at full brightness for a minute, also with overflow, then gradually returns to the main mode of the cloud according to the illumination.
Cloud mode, the first sample. Video sped up 5 times
3r3r1616. Thunderstorm 3r3167. - it turns on with a sharp decrease in external lighting (but not until complete darkness, so as not to hit the eyes in the dark) or three claps. Random LEDs (from one to 4x) flash, with a random pause between flashes. A little zamorochilsya and made "runs" of lightning in the cloud, when the LEDs flash on a temporary chain. It also looks quite like a thunderstorm. Because of the thunderstorm mode, we had to compromise PWM filtering so that the flashes would be sharp (77 ms). The duration of a “thunderstorm” depends on the external lighting - the darker, the longer, from 4 to 12 flashes.
3r3r1616. Dawn [/b] - turns on with a sharp increase in ambient light. The most difficult to set up mode, to get "the natural change of colors of the sun at dawn in a light haze" was not easy. Balancing the RGB LED had to manually almost every level of PWM, and selecting dependencies. But in the end, I got a more or less interpolation formula. Dawn lasts 40 seconds, then the transition to normal mode.
Electronics and software for those interested: 3r3323230.
3r3185. Archive source 3r3198.
3r3191. Scheme in pdf
3r3197. PCB layout, one side 3r3198.
The design of the cloud is quite simple; I made it from sintepukh (one cushion 40x40 cm), the board is placed inside on hangers of threads. The LEDs are arranged as uniformly as possible in the volume, and, well, the RGB-LED is at the bottom, and the photo sensor is at the top.
In the process of dabbling down
There were difficulties in fixing sintepukha, as it is covered with silicone to counteract caking. The lower part of the cloud is supported by narrow strips of scotch on a wire frame.
Questions, comments, suggestions, write in the comments.
Great weather for everyone!