PWM

PWM

Attiny85 PWM Implementation

Sources

#include <Arduino.h>
int ov = 0;

void setup() {
    // initialize i/o
    pinMode(PIN_B0, OUTPUT);
    pinMode(PIN_B2, INPUT);
    // put initial default saw
    analogWrite(PIN_B0, 1);
}

void loop() {
    int v = analogRead(A1); // read ADC
    double c = ((double)v) / 184.5;
    v = exp(c) - 1; // build a custom curve
    if (ov != v) {
        analogWrite(PIN_B0, v); // change PWM
        ov = v;
    }
    delay(10);
}

Schema

Schema

PCB

PCB