Beispielprogramm 2 - Hardware und Software PWM
const int pins[] {9,10,11,A0,A1,A2};#include <SoftPWM.h>void setup() { // put your setup code here, to run once: for(int i = 0; i<3; i++) { pinMode(pins[i], OUTPUT); digitalWrite(pins[i], HIGH); } Serial.begin(115200); Serial.println("Test");
SoftPWMBegin(); SoftPWMSet(A0, 0); SoftPWMSet(A1, 0); SoftPWMSet(A2, 0); SoftPWMSetFadeTime(A0, 1000, 1000); SoftPWMSetFadeTime(A1, 1000, 1000); SoftPWMSetFadeTime(A2, 1000, 1000); SoftPWMSet(LED_BUILTIN, 0); SoftPWMSetFadeTime(LED_BUILTIN, 1000, 1000);}int j = 0;void loop() { // put your main code here, to run repeatedly:for(int i = 0; i<3; i++){ analogWrite(pins[i], j);}for(int i = 3; i<6; i++){ SoftPWMSet(pins[i], j);}
SoftPWMSet(LED_BUILTIN, j*2);
if(j<128){ j++; }else{ j = 0;}
delay(100);}