analogWrite()

Writes an analog value (PWM wave) to a pin. Can be used to light a LED varying brightnesses or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady square wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite() on the same pin) Writes an analog value (PWM wave) to a pin. Can be used to light a LED varying brightnesses or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady square wave of the specified duty cycle until the next call to analogWrite() PWM 1-4 works at 488 Hz. If you need faster operation, use zunoFastPWM() on A0. Check Z-Uno pinout By default Z-Uno2 works at 488 Hz for backward compatibilty. You can tweak carrier frequency youself in wide range using analogWriteFrequency. analogWrite occupies TIMER1 hardware. You are able to use only 4 channels simylteniously. analogWrite(pin, value) pin the pin to write to: PWM1, PWM2, PWM3 and PWM4 the pin to write to. You can use any pin for this functionality, but up to 4 channels simylteniously. value the duty cycle: between 0 (always off) and 255 (always on) (see analogWriteResolution() for more details) the duty cycle: between 0 (always off) and 255 (always on) (see analogWriteResolution() for more details). Use 0 to release one of occupied PWM channels. None Sets the output to the LED proportional to the value read from the potentiometer.

int val = 0;                   // variable to store the read value
void setup() {
}
void loop() {
  val = analogRead(A3);        // read the input pin
  analogWrite(PWM1, val / 4);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
}
analogWriteResolution() analogWriteFrequency()