very simple 4ch PWM output demo for "mbed LPC824"

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 #define     PI          3.14159265
00004 
00005 PwmOut pwm[]    = {
00006     PwmOut( dp6 ),
00007     PwmOut( dp7 ),
00008     PwmOut( dp8 ),
00009     PwmOut( dp9 ),
00010 };
00011 
00012 int main()
00013 {
00014     int     count   = 0;
00015     float   t       = PI / 40.0;
00016 
00017     while(1) {
00018         for ( int i = 0; i < 4; i++ ) {
00019             pwm[ 0 ]    = powf( sin( t * (float)(count +  0) ), 2.0 );
00020             pwm[ 1 ]    = powf( sin( t * (float)(count +  5) ), 2.0 );
00021             pwm[ 2 ]    = powf( sin( t * (float)(count + 10) ), 2.0 );
00022             pwm[ 3 ]    = powf( sin( t * (float)(count + 15) ), 2.0 );
00023         }
00024         wait_ms( 20 );
00025         count++;
00026     }
00027 }
00028