This is the final version of Mini Gateway for Automation and Security desgined for Renesas GR Peach Design Contest

Dependencies:   GR-PEACH_video GraphicsFramework HTTPServer R_BSP mbed-rpc mbed-rtos Socket lwip-eth lwip-sys lwip FATFileSystem

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Embed: (wiki syntax)

« Back to documentation index

PwmOut Class Reference

PwmOut Class Reference
[Drivers]

A pulse-width modulation digital output. More...

#include <PwmOut.h>

Public Member Functions

 PwmOut (PinName pin)
 Create a PwmOut connected to the specified pin.
void write (float value)
 Set the ouput duty-cycle, specified as a percentage (float)
float read ()
 Return the current output duty-cycle setting, measured as a percentage (float)
void period (float seconds)
 Set the PWM period, specified in seconds (float), keeping the duty cycle the same.
void period_ms (int ms)
 Set the PWM period, specified in milli-seconds (int), keeping the duty cycle the same.
void period_us (int us)
 Set the PWM period, specified in micro-seconds (int), keeping the duty cycle the same.
void pulsewidth (float seconds)
 Set the PWM pulsewidth, specified in seconds (float), keeping the period the same.
void pulsewidth_ms (int ms)
 Set the PWM pulsewidth, specified in milli-seconds (int), keeping the period the same.
void pulsewidth_us (int us)
 Set the PWM pulsewidth, specified in micro-seconds (int), keeping the period the same.
PwmOutoperator= (float value)
 A operator shorthand for write()
 operator float ()
 An operator shorthand for read()

Detailed Description

A pulse-width modulation digital output.

Synchronization level: Interrupt safe

Example

 // Fade a led on.
 #include "mbed.h"

 PwmOut led(LED1);

 int main() {
     while(1) {
         led = led + 0.01;
         wait(0.2);
         if(led == 1.0) {
             led = 0;
         }
     }
 }
Note:
On the LPC1768 and LPC2368, the PWMs all share the same period - if you change the period for one, you change it for all. Although routines that change the period maintain the duty cycle for its PWM, all other PWMs will require their duty cycle to be refreshed.

Definition at line 58 of file PwmOut.h.


Constructor & Destructor Documentation

PwmOut ( PinName  pin )

Create a PwmOut connected to the specified pin.

Parameters:
pinPwmOut pin to connect to

Definition at line 66 of file PwmOut.h.