Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

The analogWrite() function is used to generate a PWM (Pulse Width Modulation) output signal on compatible pins.

The 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:

analogWrite(pin, value);

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 tag.

history | excerpt history