Pulse Width Modulation Technique is Used for sending analog signals from Arduino.
You would be seeing two unfamiliar terms:
Duty: A 25% duty cycle means that for 25% of the time the signal is at its HIGH value that is 5 V and for the rest of the 75% time it is at LOW value.
analogWrite(): This function is used in passing Analog Values to the Arduino Pins.
In the above Example:
- AnalogWrite(0) means the signal will always be at its low value.
- AnalogWrite(255) means the signal will always be at its HIGH value.
- AnalogWrite(127) means that the signal will be at its HIGH value for 50 % of its time.
In the duty cycle of 25 percent, it is high 25 percent of the time and low 75% of the time. The frequency of this square wave, in the case of the Arduino, is about 490Hz. In other words, the signal varies between high (5V) and low (0V) about 490 times every second.
So, if you are not actually changing the voltage being delivered to an LED, why do you see it get dimmer as you lower the duty cycle?
It is really a result of your eyes playing a trick on you! If the LED is switching on and off every 1ms (which is the case with a duty cycle of 50 percent), it appears to be operating at approximately half brightness because it is blinking faster than your eyes can perceive.
Therefore, your brain actually averages out the signal and tricks you into believing that the LED is operating at half brightness.