ES305 Lab 2 Exercise 3 PWM output to OScope

Dependencies:   mbed

main.cpp

Committer:
brianconnett
Date:
2014-08-14
Revision:
0:2da13a76baf2

File content as of revision 0:2da13a76baf2:

//****************************************
//  ES305 Linear Control Systems
//  Lab 2 - Introduction to mbed microcontroller
//  Exercise 3 - Pulse Width Modulation
//  Adjusts Pulse Width Modulation output. From Pin22 and displays on attached Oscilloscope
//
//  Brian Connett, LCDR, USN
//****************************************

#include "mbed.h"                           //mbed header file from mbed.org includes MOST APIs required to operate LPC

PwmOut pwm1(p22);                           //Creates a pulse-width modulation digital output assigned to the variable pwm1 at Pin22

int main()
{

    pwm1.period(0.010);                     //Set PWM period to 10ms
    pwm1.period_ms(10);                     //Set PWM period to 10ms (alternative)
    pwm1.period_us(10000);                  //Set PWM period to 10ms (alternative)

    pwm1.write(0.5);                        //set duty cycle to 50%
    pwm1=0.5;                               //set duty cycle to 50% (alternative)

}