ES305 Lab 2 Exercise 3 PWM output to OScope

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
brianconnett
Date:
Thu Aug 14 16:15:16 2014 +0000
Commit message:
ES305 Lab 2 Exercise 3; Create a PWM signal to be viewed on the OScope

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Aug 14 16:15:16 2014 +0000
@@ -0,0 +1,24 @@
+//****************************************
+//  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)
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Aug 14 16:15:16 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6213f644d804
\ No newline at end of file