Simple example. Showcase your RGB-LED using PWM for smooth transitions.

Dependencies:   mbed BLE_API nRF51822

Files at this revision

API Documentation at this revision

Comitter:
larshb
Date:
Fri Nov 23 19:47:18 2018 +0000
Commit message:
initial commit

Changed in this revision

BLE_API.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.bld Show annotated file Show diff for this revision Revisions of this file
nRF51822.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BLE_API.lib	Fri Nov 23 19:47:18 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/Bluetooth-Low-Energy/code/BLE_API/#65474dc93927
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Nov 23 19:47:18 2018 +0000
@@ -0,0 +1,21 @@
+#include "mbed.h"
+#include <cmath>
+
+PwmOut R(LED1);
+PwmOut G(LED2);
+PwmOut B(LED3);
+
+#define PI 3.14159265358979323846
+
+#define MAX(a,b) a>b?a:b
+
+int main() {
+    float t = 0.0;
+    while(1) {
+        t+=0.01;
+        R = MAX(sin(t-0*PI/3),0);
+        G = MAX(sin(t-2*PI/3),0);
+        B = MAX(sin(t-4*PI/3),0);
+        wait(0.01);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Nov 23 19:47:18 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5571c4ff569f
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nRF51822.lib	Fri Nov 23 19:47:18 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/Nordic-Semiconductor/code/nRF51822/#c90ae1400bf2