obniz to be used
Rsponse waiting timeout in milliseconds
Set pulse duty in terms of ratio.
// Javascript Example
var pwm = obniz.getFreePwm();
pwm.start({io:0});
pwm.freq(2000); // set pwm frequency to 2khz
pwm.duty(50) // set pwm pulse width 50%
Calls each of the listeners registered for a given event.
It stops pwm and releases io.
// Javascript Example
var pwm = obniz.getFreePwm();
pwm.start({io:0});
pwm.end();
Return an array listing the events for which the emitter has registered listeners.
Set frequency, not pulse duration.
For example, this value will be 1khz with DC motor.
// Javascript Example
var pwm = obniz.getFreePwm();
pwm.start({io:0});
pwm.freq(1000); // set pwm. frequency to 1khz
frequency (Hz)
Return the number of listeners listening to a given event.
Return the listeners registered for a given event.
This modulates pwm with data.
Modulation can be chosen from below.
data "1" means put out the pwm with duty ratio of 50%. "0" means stop pwm. io will be 0. Interval defines the symbol baud rate. Duty is fixed at 50%.
This is useful to generate IR signal (Remote control). Frequency of 38kHz gets modulated with signals.
data array. All data[index] is 0 or 1.
Add a listener for a given event.
Add a one-time listener for a given event.
Set pulse duty
// Javascript Example
var pwm = obniz.getFreePwm();
pwm.start({io:0});
pwm.freq(2000); // set pwm frequency to 2khz
pwm.pulse(0.5) // set pwm pulse 0.5ms. so this is 25% ratio.
pulse time (ms).
Remove all listeners, or those of the specified event.
Remove the listeners of a given event.
This starts a pwm on a given io. freq=1khz, duty=0% at start.
io drive and pull can be configured. See more details on io
// Javascript Example
var pwm = obniz.getFreePwm();
pwm.start({io:0}); // start pwm. output at io0
pwm.freq(1000);
pwm.duty(50);
var pwm2 = obniz.getFreePwm();
pwm2.start({io:1, drive:"open-drain", pull:"5v"});
Generated using TypeDoc
We will now generate PWM. Maximum current depends on the driving mode. See io.