element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Photonics
  • Challenges & Projects
  • Project14
  • Photonics
  • More
  • Cancel
Photonics
Blog Candle in the wind
  • Blog
  • Forum
  • Documents
  • Events
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Photonics requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: redcharly
  • Date Created: 13 Apr 2020 10:00 PM Date Created
  • Views 328 views
  • Likes 11 likes
  • Comments 7 comments
  • photonicsch
  • nanoramach
Related
Recommended

Candle in the wind

redcharly
redcharly
13 Apr 2020

Introduction

This project is a simple game that inspired my 4-year-old son.

I saw him spellbound looking at the flame of a candle, the candle of a birthday cake. I tried to make him play a bit with LEDs but the charm of a flame that moves as if it were alive cannot be equaled by a cold LED.

Looking at the flame of a candle, I tried to simulate it with a simple circuit that can be used to introduce some of the potentials of an Arduino board to my students.

 

 

If we look closely at the flame of a candle, we can see that it takes on different colors. Below, near the wick, there will be bluish shades, while going up the color changes from blue to red-orange to get bright yellow. In addition to this chromatic variation, we will also have to take into consideration the effect of the convective currents that cause the flame to wave and move continuously in an unpredictable way, especially in its upper part.

These two aspects relating to a candle flame can be modeled using Arduino's PWM modulation and Random function.

This is therefore an excellent opportunity to show students what PWM modulation is and what its typical uses are.

 

 

Pulse Width Modulation

Pulse Width Modulation (PWM) is one of the most used modulations.

It is in fact used not only in telecommunications but also in applications where there is the need to vary the brightness of a lamp or to adjust the speed of an electric motor in direct current.

It is in fact used not only in Telecommunications but also in other applications for example when there is the need to vary the brightness of a lamp or to adjust the speed of electric DC motors.

The PWM modulator is a circuit that receives two signals at its input, the modulating signal, that is, the one that regulates the width of the square wave (the duty cycle) at the output and a triangular wave signal with a fixed frequency. At the output we will find a square wave signal that has the triangular signal frequency and a variable duty cycle that depends on the amplitude of the modulating signal.

 

                                       (From Arduino Site)

 

 

Many years ago this topic was treated at school using the "mythical" NE555, an integrated circuit that used with three or four other passive electronic components could be used as a monostable, astable or bistable multivibrator, as a PWM and PPM modulator, as a comparator, etc.

 

                                           

Since Arduino entered our schools, making a simple fader for a LED or a speed control for a small fan has become even simpler.

In these simple cases, the standard PWM frequency of the most popular Arduino boards is 490 Hz, a perfect frequency for our purposes so it will not be necessary to access the registers to set higher frequencies.

Even Arduino Nano has several PWM output terminals, in particular, the pins that can be used are 3, 5, 6, 9, 10 and 11.

The default frequency of the PWM signal is by default 490 Hz but it can be varied using a little more code complex but in any case, you cannot exceed a few tens of kHz.

 

To get a PWM signal on Arduino just use the analogWrite () function. Its syntax is very simple:

 

     analogWrite(pin, value)

 

Parameters:

  • pin: the Arduino pin to write to. Allowed data types: int.
  • value: the duty cycle: between 0 (always off) and 255 (always on). Allowed data types: int.

 

 

We will use this function to try to recreate the colors of the candle flame.

 

We will use a matrix of 15 LEDs organized as shown. The candle flame will be represented by 5 lines of three LEDs.

Starting from the bottom there will be a blue line, a red line and three yellow lines. In practice, we will use PWM to manage the three colors so that the light produced resembles that produced by a candle.

The two central LEDs of the fourth and fifth row will be controlled together with those of the third row while the two pairs of yellow LEDs on the right and left are piloted by two other doors in order to light up with a random intensity at each cycle.

Their flashing will simulate the random movement of the flame and its variation in intensity.

 

 

 

The Circuit

Per quanto riguarda il circuito non c’è molto da dire, lo schema è piuttosto banale e basta leggere il codice per connettere i Led ed il gioco è fatto.

 

        

         

 

 

The code is very simple, I added lines of code that could be avoided in order to make it more understandable.

 

The effect obtained is quite pleasant, even considering the fact that everything was made in a very short time and with materials that I was at home.

 

In Italy we are still forced to stay home for Covid 19 and everything is closed, I am dusting off old boxes full of old discrete electronic components and, I must admit that the temptation to do everything with the old NE555 has occurred to me several times but I believe Arduino can be more useful to me in view of the next school year. In fact, I am preparing many simple projects to show my students some uses of Arduino and some IoT applications.

 

 

You don't have permission to edit metadata of this video.
Edit media
x
Upload Preview

Anonymous

Top Comments

  • dubbie
    dubbie over 2 years ago +2

    Carlo,

     

    A nice clean implementation, I especially like the casing that you used. Was this was some other 'bulb'?

     

    Dubbie

  • redcharly
    redcharly over 2 years ago in reply to dubbie +2

    Exotic bulb, isn't it, dubbie??

  • Fred27
    Fred27 over 2 years ago +2

    The end result looked far better than I was expecting!

     

    I'm sure I've read an interesting investigation into how commercial "candle" LEDs work. I just went off on a tangent looking for some of these. One…

  • Fred27
    Fred27 over 2 years ago

    The end result looked far better than I was expecting!

     

    I'm sure I've read an interesting investigation into how commercial "candle" LEDs work. I just went off on a tangent looking for some of these. One just plays a tune!

    • Cancel
    • Up +2 Down
    • Reply
    • More
    • Cancel
  • redcharly
    redcharly over 2 years ago in reply to dubbie

    Exotic bulb, isn't it, dubbie??

    • Cancel
    • Up +2 Down
    • Reply
    • More
    • Cancel
  • dubbie
    dubbie over 2 years ago

    Carlo,

     

    A nice clean implementation, I especially like the casing that you used. Was this was some other 'bulb'?

     

    Dubbie

    • Cancel
    • Up +2 Down
    • Reply
    • More
    • Cancel
  • redcharly
    redcharly over 2 years ago in reply to jw0752

    Yes jw0752 , let's say that if you see the "candle" lit at a certain distance it is quite likely. Making the changes proposed by genebren  the result will be even better. Even now the slight bluish tinge at the bottom and the flashing of the upper part managed by the random function are very faithful to the originals. As soon as I make the changes in the colors of the LEDs, I will do the test you proposed to me, I think that talking about AI at school is necessary and teachers need to take advantage of every little opportunity to do it.

    Thanks for your comment

    • Cancel
    • Up +1 Down
    • Reply
    • More
    • Cancel
  • redcharly
    redcharly over 2 years ago in reply to genebren

    True genebrenusing different colored LEDs, the result could have been better. If I replaced the red LEDs with the orange ones and the yellow ones with the warm white ones, I believe that the result would be even more similar to that of the photo.

    Bringing such a simple project to school, I believe, can be useful as it allows you to become familiar with an important concept such as PWM to create simulations of simple analog physical phenomena.

    My son also appreciated a lot because he was my "helper" in the realization !! For more than a month he has been closed at home because of Covid and has not seen other children, one of the opportunities for recreation is "dad's toys"!

    Thanks for your comment

    • Cancel
    • Up +1 Down
    • Reply
    • More
    • Cancel
>
Element14

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2022 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube