Electronic Candle | MindPlus Coding Kit for Arduino Started Tutorial E11

0 3759 Easy
projectImage

The most anticipated moment for each birthday is when you make a wish with a candle on the birthday cake. Turn off the light, light up the candle. Make a wish with hands kept together. At last, take a deep breath and blow out the candles. It is a heartwarming moment when your family’s good wishes and smiles surround you, amid the shimmering candle light.

However, when we eat the cake, drops of candle wax always spoil the taste and ruin the moment. Is there a way to do away with wax?

Let's try to make some electronic candles together.

projectImage

Task Navigation

1. Understanding random numbers

2. Make an electronic candle

Command List

projectImage

Hands-On

Hardware connection

Connect the red LED light to Digital Pin 10, the analog sound sensor to Analog Pin A0, and the analog light sensor to Analog Pin A1.

projectImage

Hardware connection (LED-R-10, analog sound sensor-A0, analog light sensor-A1)

Please match the colors when plugging

If you paid attention to details, you might have realized that the hardware connections are identical to the ones we used in stairs light section. The reason is that we are still controlling the LED light module by sound and light. The only difference is the effect we are after. The previous one is turning on / off, while the current one is the shimmering light effect of candles.

Programming

1. Write the program

1) Click on the extension to add "Analog Sound Sensor" and "Analog Ambient Light Sensor" to the sensors

2) Serial port reads sound intensity and ambient light intensity

3) Setting conditions: the candle keeps flickering in the dark environment to achieve the candle effect.

projectImage

1) Then, sound intensity brings the candle “blown out” effect.

2. Reference program

projectImage

3. Program results

When indoor lighting is off, LED turns on and flickers; when air is blown into MIC, LED turns off.

4. Program analysis

For flicker effects, we introduced a random number module. PMW controls the brightness and outputs brightness determined by random number. When Arduino obtains sound signals (when we blow out the candle), candle goes out.

projectImage

Further Reading

Gesture-controlled LED

With the development of science and technology, human-computer interaction has become an important part of people's daily life. The advances of visual computing, especially, enable computers to "see" the user's actions. Among them, gesture recognition is a key technology that is indispensable for ushering a new generation of human-computer interaction.

Gesture can have various directions, such as left to right, right to left, top to bottom, bottom to top, and so on. For Arduino beginners, it’s certainly difficult to make gesture recognition work. For these reasons, we design a simple gesture recognition pattern here, which is using two sensors to determine the chronological order of gestures to make out the direction. There are many scenarios when it comes to gesture-controlled LED. We have designed three solutions here:

1) Solution 1: By the gesture direction detected by the sensors, a left to right gesture would turn on LEDs while right to left gesture would turn off.

2) Solution 2: By the gesture direction detected by the sensors, a left to right gesture turn on LEDs from left to right, while a right to left gesture would turn off LEDs from right to left.

3) Solution 3: By the gesture direction detected by the sensors, a left to right gesture turns on red LEDs while a right to left gesture turns on green LEDs. If a gesture is present for 3 seconds or longer, turn off LEDs.

Here is a brief introduction to solution 1: "By the gesture direction detected by the sensors, a left to right gesture would turn on LEDs while right to left gesture would turn off."

projectImage

Required hardwares

LED x 1

DFRobot digital anti-fall sensor x 1

Arduino UNO x1 (or other main control board)

Design concept

projectImage

Further Exercise

With concepts provided by “Further Reading”, can you make a gesture-controlled LED?

icon Program 4-3 E11.rar 165KB Download(1)
License
All Rights
Reserved
licensBg
0