Example using timer based PWM with onboard LEDs

Dependencies:   MAX326XXFTHR_PwmOut

Files at this revision

API Documentation at this revision

Comitter:
jessexm
Date:
Tue May 01 16:11:58 2018 +0000
Commit message:
Initial commit

Changed in this revision

MAX326XXFTHR_PwmOut.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r e2e3c0c948a0 MAX326XXFTHR_PwmOut.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MAX326XXFTHR_PwmOut.lib	Tue May 01 16:11:58 2018 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/teams/MaximIntegrated/code/MAX326XXFTHR_PwmOut/#bb005bb0a24c
diff -r 000000000000 -r e2e3c0c948a0 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue May 01 16:11:58 2018 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+#include "MAX326XXFTHR_PwmOut.h"
+
+MAX326XXFTHR_PwmOut led[] = {
+    MAX326XXFTHR_PwmOut(LED1),
+    MAX326XXFTHR_PwmOut(LED2),
+    MAX326XXFTHR_PwmOut(LED3)
+};
+
+int main()
+{
+    float dc;
+    unsigned int idx = 0;
+
+    while (1) {
+        for (dc = 0.0f; dc <= 1.0f; dc += 0.01f) {
+            led[idx % 3].write(dc);
+            led[(idx + 1) % 3].write(1.0f - dc);
+            wait_ms(20);
+        }
+        idx++;
+    }
+}
diff -r 000000000000 -r e2e3c0c948a0 mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Tue May 01 16:11:58 2018 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#c05d72c3c005fbb7e92c3994c32bda45218ae7fe