Inspiration

Because when I am at home, I often go to the outdoor music fountain near my house. Every time I go, I always involuntarily immerse myself in attractive fountain performances with beautiful music. Therefore, we decided to build a mini version of a musical fountain. The fountain allows us to play a favorite song by ourselves every time we miss home and watch the performance of the fountain to ease our thoughts and emotions.

What it does

It is composed of 9 central water pumps, two side pumps and a RGB light strip. We have an external sound sensor. By playing different music outside, the shape of the water column and the color of the light strip will change accordingly.

How we built it

In order to control the volume of the water pumps, we used eleven sets of BJTs to control their switches and their heights. At the same time, in order to ensure the effect of the performance, we divided the eleven pumps into three groups. Two groups of them use two different TIMERs in order to generate PWM signals of different duty cycles, so that their performances are hierarchical. The second group will be turned on when the first group of pumps reaches half the height. The third group will start when the first two sets of pumps reach their peak. Through these changes in the height of the water column, the whole performance will be more layered. At the same time, their changes are not disorderly changes. We obtain the sound signal we want by processing the analog signal of the external sound obtained by the sound sensor. We use these sound signals to control the height of the water column pump and at the same time control the color change of the light strip.

Challenges we ran into

First of all, we want to verify the feasibility of the components and first master the use of sensors. Since the power of the water pump we bought can be controlled by changing the DC voltage attached to it, we envisioned using DAC to generate different voltages to control the height of the water pump at the beginning. But owing to the limitation of the output current of the DAC, it’s impractical even to drive one water pump with DAC. So we gave up using DAC to adjust the voltage to drive our pump. Therefore, we tried another way. Just like what we did in LAB3, we used BJT to control the current of the pump, thereby controlling the height of the water column. After several attempts, we found that this idea is feasible, so we applied this method to all other water pumps to control the water column height.

Secondly, when we studied the sound sensor, we started to use the digital signal it generates. That is to say, the digital output signal will be transformed when it detects a sound change. We take the number of signal changes over a period of time to get the approximate volume change range. Because the digital signal change threshold of the sound sensor is too high, the volume change obtained is not very ideal, and the source of the sound must be very close to the microphone of the sound sensor to get an approximately ideal result. For this reason, we also made an external sound amplifier. A few days later, we saw the video of other people using the sound sensor and felt why other people's sound sensors are so sensitive, and the threshold is very low, the pronunciation source is far away and the sound change can be detected. So we have doubts about the way we use sound sensors. After we re-researched it, we found that its analog output signal is very sensitive, so we processed the analog signal to get the volume change amplitude by calculating the number of changes above the threshold that we determined within a certain period of time.

Finally, we thought that the use of light strips would be the easiest thing, but when we really started to study light strips, we found that things were not as simple as we thought. By looking at the datasheet of the light strip, we know that it is necessary to generate a signal with a certain duty cycle and a frequency of 800kHz to input the data into the light strip. So our starting idea is to use another TIMER PWM to generate the corresponding frequency. By setting the corresponding OCR1A, we can get the desired frequency. But the problem is that we have to continuously change the duty cycle of the PWM to transfer the desired color data to the light strip. First, we used interrupt to count and change to another duty cycle after reaching the number we set. But the output wave can never be counted correctly according to our expectations. For instance, we want it to have a duty cycle of 28% and change to 72% after 8 periods, but we finally get the duty cycle changed after 25 periods. We guess that it may be because the frequency is too fast, any code in our interrupt will occupy a certain amount of running time, resulting in the inability to change quickly. After we studied for a long time, we gave up this method of using PWM. But we thought, since the instructions take up time, why don't we use some instructions to control the length of the output 1 and 0 of the separate IO port, so as to achieve an effect similar to PWM. Sure enough, we found that the null instruction will run for a short period of time while the system does nothing. By using different numbers of empty commands, we successfully wrote 0 and 1 that can be transmitted to the light strip. Through these 0 and 1, we can perfectly control the color change of the light strip.

Accomplishments that we're proud of

The height of our water column changes obviously with the rhythm of the music, which meets our expectations.

We have mastered the new LED components, and we can write the library that controls the color change of the LED by ourselves

Master how to control the sensitivity of the sound sensor, and can get the change of the external volume through the algorithm.

What we learned

We have consolidated all the knowledge in the previous lab and can use Atmega328P more handily.

We learned how to use the sound sensor.

We learned how to control the IO port to generate a waveform similar to the PWM signal.

Learned how to use a water pump.

Learned teamwork.

What could be a next step for this project?

What we ultimately want is to further optimize our lighting changes. Due to time, we did not adjust the lighting changes more carefully, and thus did not achieve a very silky feeling. So our next goal is to optimize the code to make the lights that change with the music more smoothly.

The second is that we can add some tricks when the water pump sprays, such as spraying one by one, and so on.

Built With

Share this project:

Updates