The analogWrite() function is used to generate a PWM (Pulse Width Modulation) output signal on compatible pins.
analogWrite() function is part of the standard Arduino library. It does not allow true digital-to-analog conversion. Rather, it generates a PWM (Pulse Width Modulation) output signal on any compatible pin.
It has the following syntax:
The first parameter identifies the IO pin number to generate the signal on. The second parameter should be in the range 0-255, and specifies the duty cycle to use (0 is 'always off', 255 is 'always on').
Full documentation is available online here: http://arduino.cc/en/Reference/AnalogWrite
Note: Please only use this tag for questions which are specific to the
analogWrite() function. For questions about PWM in general, please use the pwm tag.