Pulse Width Modulation(PWM), is a common hardware interface and controls analog devices with digital outputs.For more information, please visit here.
- Please click here if you are not sure how to use Ruff to write apps.
- Please read Driver - Getting Started and Driver Model for more information about the driver development.
Please read the datasheet to confirm that the interface is PWM.
Please ensure your interface is PWM in driver.json and declare it as PWM. The declaration should be inputs with type as PWM.
The following properties is accepted by PWM:
frequency- setup output square wave frequency.
- PWM has two methods:
setDuty- setup duty for PWM. The argument is a float that rangs from 0 to 1.
setFrequency- setup output square wave frequency, whose unit is Hz.
- Please visit PWM API document for more details.
The LED module has three PWM intefaces (R,G,B) whose output square wave frequency is 800Hz. Please declare them in driver.json.
We provides buzzer with four methods:
- setRGB - setup duty for R, G, B to adjust LED color.
- getRGB - return to current RGB value.
- turnOn - setup R, G, B to 1 to make LED white.
- turnOff - setup R, G, B to 0 to make LED black.