I was learning Pulse Width Modulation and it told me that it just the technique to change the amount of time the signal gets high in one wave, but why am I able to see the bulb glowing at all the time even if the duty cycle is set to 40%.
It's due to the response of the eye and brain to rapid variations of light intensity.
Persistence of vision traditionally refers to the optical illusion that occurs when visual perception of an object does not cease for some time after the rays of light proceeding from it have ceased to enter the eye. The illusion has also been described as "retinal persistence", "persistence of impressions", simply "persistence" and other variations. According to this definition, the illusion would be the same as, or very similar to positive afterimages. Source: Persistance of vision.
There is more in the linked article.
If you move the PWM display across your field of vision while looking straight ahead you should be able to see the strobing effect. I've also managed to see it during humming while looking at a multiplexed LED display. You need to vary the pitch of your humming until your eyeballs vibrate at a multiple of the strobe frequency. It's quite weird!
Depends on PWM rate (frequency) and what light source you use. It also depends on the ability of the person to detect the blinking as it varies.
If you apply 10 Hz PWM to a LED to turn it simply on and off at 40% duty rate, you will see it being on and off, at least when moving it. People don't have a fixed "flicker fusion threshold" so the point where it can or cannot be seen varies between people. If you apply high enough PWM rate like 10 kHz, nobody will be able to see it blinking any more.
If the light source is an incandescent bulb, the filament stays glowing hot even when it does not receive power, so 10 Hz PWM rate will be fine.
At frequencies above the flicker fusion frequency, pulsing light is perceived as steady light at an average intensity.
Note that the minimum frequency varies with light intensity and where the light is in your field of vision (peripheral vision is more sensitive to flicker) and other factors, as described in the linked Wiki article.
If there is relative motion between the light source and your eyeball you can perceive something like the a multiplexed LED display or indicator "breaking up" into dots characters because the light hits different receptors in your eye. For this reason it's good to keep the frequency well above the minimum, especially where vibration is involved. More like 1kHz than a few tens of Hz.
An interesting parlor trick (courtesy of John Larkin) is that if you look at the screen of an old-fashioned analog oscilloscope with the trace sweeping at an appropriate rate, and whack yourself on the top of the head, you will see a trace representing the control system tracking response of your eyeball.