I have a question and I was just thinking that you can help me out with that. I was studying how to create simple circuit, that is involving bulb, wire and battery and came up with question, how does actually electrons produce light energy in the bulb? What I know is there is so-called the filament, a thing with great resistance, and this thing heat-up when current is flowing and it produce light, but I still don't understand how it's possible. Light energy includes photons. Electrons can emit or absorb photons. Does that mean, that they already had photons?
The bulk matter of the wire is made of metal containing a “sea” of electrons. These act as a liquid in a sense, and in particular can vibrate due to thermal motions. For nonmetals the electrons in bulk material (e.g. mineral grains) can vibrate in ways more free than the absorbing/emitting energy level thing: the phonons can take just about any energy.
Black-body radiation at some hot femperature is why incandescent lightbulbs and candle flames and electric stove burners and the surface of the sun emit light.
What I know is there is so-called the filament, a thing with great resistance, and this thing heat-up when current is flowing and it produce light, but I still don't understand how it's possible. Light energy includes photons. Electrons can emit or absorb photons. Does that mean, that they already had photons?
Think about how the filament heats up when the current flows through it. As the electrons move along through the filament, they are constantly bumping into the atoms that make up the filament, transferring their energy to them. The energy of each impact vibrates an atom -- in other words, the current heats the atoms up.
Now, the bound electrons in the vibrating atoms may be boosted temporarily to a higher energy level when they're hit by on-coming high-energy electrons that form the electric current. After the energy is transferred to the bound electrons, they fall back to their normal levels. This happens when the electrons release the extra energy, that they had absorbed via the collision, in the form of photons.
Note that the absorbed energy may be released in other forms energy than photons depending on the material in question etc. So the electrons(ones inside the filament) did not already have photons- they were given some energy, which for the choice of material in the bulb, leads to an emission of photons when the electrons relax from that excited high-energy state.
Rather than looking at an incandescent bulb, let us consider an LED (light emitting diode). In terms of building a circuit out of it, it is no different from a light bulb (at least the differences are not relevant here). The point is, that in an LED, the microscopic mechanism simply is that an excited electron relaxes to its ground state, emitting light. From your question, I understand that this is a concept you are familiar with. In contrast, a filament emits light because it is hot. The microscopic description (with electrons and atoms) is much more complicated here.
Back to your question!
Upon emission, the photon is literally created. It did not exist before.
Your intuition tells you that 'the number of photons' must be conserved. Actually, the conserved quantity you are looking for is energy. Some quantum of energy (e.g. potential or electrical, or, in the case of an LED, it's the excited energy of an electron) is converted into a quantum of radiation. This quantum of radiation is called a photon. The same energy existed before! It was just present in a different form, but still in quanta. We just don't usually give special names to it. Still, sometimes physicists talk about phonons, vibrons, magnons, etc. They all describe quanta of some energy degree of freedom.
The simplest answer is that the filament heats up and gets so hot that it glows.
As to how it heats up; the electric field forces electrons to rush around the circuit. They encounter a lot of resistance in the filament and it is this "friction" that leads to heating.
As to why hot things emit light; heat is energy and the increase in energy in the filament means that electrons can jump to higher energy levels in the atoms (excitation). When they de-excite, they emit photons.