analogWrite vs SoftPWM

Hi,

I have 2 versions of some very simple test code that produces a PWM signal, one uses the Arduino anlogWrite and the other uses SoftPWM. the SoftPWM behaves irattically.

I have added both sets of code and pictures showing the wave forms below. you can see the bottom picture is irratic.

#include "SoftPWM.h"

void setup()
{
  //SoftPWMBegin();
  //SoftPWMSet(3, 0);
  pinMode(3, OUTPUT);
  
}

void loop()
{
    delay(15);
    analogWrite(3, 255);   
    //SoftPWMSet(3, 255);
    delay(15);
    //SoftPWMSet(3, 0);
    analogWrite(3, 0);
}

#include "SoftPWM.h"

void setup()
{
  SoftPWMBegin();
  SoftPWMSet(3, 0);
  //pinMode(3, OUTPUT);
  
}

void loop()
{
    delay(15);
    //analogWrite(3, 255);   
    SoftPWMSet(3, 255);
    delay(15);
    SoftPWMSet(3, 0);
    //analogWrite(3, 0);
}

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Your topic was MOVED to its current forum category as it is more suitable than the original

It certainly looks like SoftPWM is producing bad results.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.