Table of Contents

analogWriteInit()

analogWriteInit() sets the resolution and prescaler of the output timer.

analogWriteInit command operation flow

void analogWriteInit(uint8_t ch, uint16_t top = 65535, uint16_t prescaler = 1)

Commands

Command Arguments Return Value Operation
analogWriteInit(ch, top, prescaler) uint8_t ch
uint16_t top = 65535
uint16_t prescaler = 1
void Sets the resolution and prescaler of the output timer.

Example

void setup() {
  analogWriteInit(0, 65535, 1);  // Set the output timer's resolution and prescaler.
 
  analogWrite(0, 32767);  // Approx. 50%
  analogWrite(1, 65535);  // 100%
}
 
void loop() {
}

Precautions

Built-in Commands in the Same Category

← Built-in Command List