Mozzi  version v1.1.0
sound synthesis library for Arduino

This example demonstrates the Phasor class.

/* Example of pulse width modulation,
using Mozzi sonification library.
Based Miller Puckette's j03.pulse.width.mod example
in the Pure Data documentation, subtracting 2 sawtooth
waves with slightly different tunings to produce a
varying phase difference.
Demonstrates Phasor().
Circuit: Audio output on digital pin 9 on a Uno or similar, or
DAC/A14 on Teensy 3.1, or
check the README or
Mozzi documentation/API
Mozzi help/discussion/announcements:!forum/mozzi-users
Tim Barrass 2012, CC by-nc-sa.
#include <MozziGuts.h>
#include <Phasor.h>
Phasor <AUDIO_RATE> aPhasor1;
Phasor <AUDIO_RATE> aPhasor2;
float freq = 55.f;
void setup(){
startMozzi(); // :)
void updateControl(){
AudioOutput_t updateAudio(){
char asig1 = (char)(>>24);
char asig2 = (char)(>>24);
return MonoOutput::fromNBit(9, ((int)asig1-asig2));
void loop(){
audioHook(); // required here