PWM -- Obsolete PBASIC routine


  ' PBASIC library, these routines were written for ARMexpress, and included for general reference

#include <PULSE.bas>                               ' source in /Program Files/Coridium/BASIClib

SUB PWM ( pin, duty, milliseconds)


Generate an analog signal on pin for milliseconds with a duty cycle of 0 to 255.
A duty cycle of 255 corresponds to an output value of 100%.

The IO direction of the pin will be set to output, the PWM pulse train is output, and then the pin is set to tri-state (input).  If the pin is connected to an RC filter, then the voltage will stay on the capacitor for a period of time determined by the load.


#include <PULSE.bas>

  '  Generate a 1.65 volt (half of 3.3V) on pin 4 for 6 seconds.

PWM (4, 127, 6000)

Differences from other BASICs

See also